+ 1
Can i create a multi dimensional arrays in javascript?
i am trying to build a 2d array in javascript and i am kinda stuck :X anyone have a bit of experience with multi-dimensional arrays in JS? or do i need to define multiple 1-d arrays to make sort of a 2d array? its not impossible but will complicate things
4 odpowiedzi
+ 3
exactly!
+ 2
var a = new Array ();
a [0] = new Array ();
Hope this helps!
~Kamil
+ 1
just to see if i understood - if i want a 4 * 4 matrix i do:
var arr = new Array(4);
for(var i=0 ; i<4 ; i++)
{
arr[i] = new Array(4);
}
+ 1
tried it in my code and it worked like a charm
thx for the help!