+ 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

30th Nov 2016, 6:01 AM
Ethan
Ethan - avatar
4 Réponses
+ 3
exactly!
30th Nov 2016, 10:40 AM
Kamil
Kamil - avatar
+ 2
var a = new Array (); a [0] = new Array (); Hope this helps! ~Kamil
30th Nov 2016, 6:58 AM
Kamil
Kamil - avatar
+ 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); }
30th Nov 2016, 7:05 AM
Ethan
Ethan - avatar
+ 1
tried it in my code and it worked like a charm thx for the help!
30th Nov 2016, 7:18 AM
Ethan
Ethan - avatar