javascript 2d array empty init then fill code example
Example: javscript generate empty 2d array
var grid = [...Array(width)].map(e => Array(height));
// access via grid[y][x]
var grid = [...Array(width)].map(e => Array(height));
// access via grid[y][x]