[Solved] Two dimensional array in Javascript with a certain cell size [closed]


There are no two dimensional arrays in Javascript, so you have to use a jagged array, i.e. an array of arrays.

Initialise it using literal arrays:

var arr = [[ 1, 2, 3 ], [ 4, 5, 6 ]];

Or the Array constructor:

var arr = new Array(10);
for (var i = 0; i < 10; i++) {
  arr[i] = new Array(10);
}

An array is not a visual element, so to display it you would loop through each outer and inner array, and draw something that represents each item.

1

solved Two dimensional array in Javascript with a certain cell size [closed]