If I type in the browser console Array(100).map((x,i)=> i)
it returns an empty array as follows:[empty x 100]
But if I use the spread operator [...Array(100)].map((x,i)=> i)
it returns all the indexes [0,1,2,3,4,...]
.
If I am not wrong, using the spread operator creates a shallow copy of the newly created array, but I don't understand why the map works on the second version and not also on the first.