If I write this code: Array(3).map( () => ({ a:1 }) )
I get Array(3) [ <3 empty slots> ]
instead of an array of 3 objects. Why is that?
As far as I know, Array(3)
will produce an array of undefined
elements with length 3. And for instance, [1, 2, 3].map( () => ({ a:1 }) )
produces the expected output. This is true also using any other array with length 3. I'm intrigued.