4 ms·
When creating a 2d grid array with all values the same, slicing one row multiple times works way faster than creating each row for each column. for(var y=h;
by gindevine 16y ago
When creating a 2d grid array with all values the same, slicing one row multiple times works way faster than creating each row for each column.
for(var y=h;y>=0; y--) row.push(0);
for(var x=w; x>=0; x--) grid[x] = row.slice(0);
It seems to me that this method should work without any problems, but I may be wrong..