const grid = Array.from(Array(3), e => Array(4));
Array.from(arrayLike, mapfn)
mapfn
is called, being passed the value undefined
, returning new Array(4)
.
An iterator is created and the next
value is repeatedly called. The value returned from next
, next().value
is undefined
. This value, undefined
, is then passed to the newly-created array's iterator. Each iteration's value
is undefined
, which you can see if you log it.
var grid2 = Array.from(Array(3), e => {
console.log(e); // undefined
return Array(4); // a new Array.
});