When I console.log(Array(2))
I am able to find map
prototype function. But when I use it, this returns an array of undefined.
let result = Array(2).map((o, i) => {
return i;
});
console.log(result);
I know I can use fill()
or spread operator on Array(2)
before using the map()
but I'm just wondering why I'm getting this behavior.