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 // [ [],
Array(cardinality).fill(0).map(function(item) {return [];});
where cardinality is the number of items you are looking at. In this case it would be 9. This was suggested by one of my colleagues actually. This is neat, I think :) This is valid from ECMA V6. Documentation: Array::fill