is there a shorter, better way to generate \'n\' length 2D array?
var a = (function(){ var i=9, arr=[]; while(i--) arr.push([]); return arr })(); a // [ [],
Just discovered another ES6 way with one line expression:
Array.from({length: N}, () => [])
Array.from(arrayLike[, mapFn[, thisArg]])
More detail about its implementation/polyfill ⇢ MDN Array.from()
Yet another neat solution with help of array spread syntax:
array spread syntax
[...Array(N)].map(() => [])