+ 5

Multi-Dimensional arrays in JavaScript

Does JavaScript support multi-dimensional arrays? If so, how do I use them?

26th Oct 2018, 5:40 PM
NipIsTrue
4 Réponses
+ 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 } }
27th Oct 2018, 6:48 PM
Mirko Klotzsche
Mirko Klotzsche - avatar
+ 2
can you explain how it works
27th Oct 2018, 5:52 PM
NipIsTrue
26th Oct 2018, 10:09 PM
Mirko Klotzsche
Mirko Klotzsche - avatar
+ 1
ok thank you!
27th Oct 2018, 6:51 PM
NipIsTrue