javascript define multidimensional array code example
Example 1: js array two dimensional
const matrix = new Array(5).fill(0).map(() => new Array(4).fill(0));
console.log(matrix[0][0]);
Example 2: javascript define multidimensional array
var iMax = 20;
var jMax = 10;
var f = new Array();
for (i=0;i<iMax;i++) {
f[i]=new Array();
for (j=0;j<jMax;j++) {
f[i][j]=0;
}
}
Example 3: javascript multidimensional array
var items = [
[1, 2],
[3, 4],
[5, 6]
];
console.log(items[0][0]);
console.log(items[0][1]);
console.log(items[1][0]);
console.log(items[1][1]);
console.log(items);