Last active
August 29, 2015 14:03
-
-
Save allysonsouza/ef5a700386a15e4ce5a1 to your computer and use it in GitHub Desktop.
Multidimensional Empty Arrays in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var App = { | |
cols: 3, | |
init: function() { | |
var siblings = []; | |
for(var i = 0; i < this.stage.rows; i++) { | |
siblings[i] = []; | |
} | |
for( var j = 0; j < 1; j++ ) { | |
for( var k = 0; k < 1; k++ ) { | |
//Verification | |
if( (k + 1) < this.cols ) { | |
if ( !siblings[j][k] ) { | |
siblings[j][k] = []; | |
} | |
Array.prototype.push.apply(siblings[j][k], [j, k+1]); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment