+ 5
Multi-Dimensional arrays in JavaScript
Does JavaScript support multi-dimensional arrays? If so, how do I use them?
4 Respuestas
+ 4
var arr = []; // creates a new array with dimension 1
for(a = 0; a < 10; a++) { // iterate through array (1st dim.)
arr[a] = []; // every element is assigned with a new array and arr so becomes the 2nd dimension
for(b = 0; b < 10; b++) { // iterate through 2nd dimension
arr[a][b] = a * b; // every element is filled with a value
}
}
+ 2
can you explain how it works
+ 1
ok thank you!