I expect this JS:
(new Array(3)).map(_ => 3.14)
... to yield [3.14, 3.14, 3.14]
. Instead, it yields [ <3 empty items> ]
. My questions:
What on earth "is" this weird structure I've created? It would make sense to me if it were e.g.
[undefined, undefined, undefined]
, but I don't know of a primitive JS structure called<empty item>
. It's clearly not the same as[undefined, undefined, undefined]
, because the latter would have yielded[3.14, 3.14, 3.14]
.How can I succinctly create an array
[3.14, 3.14, 3.14]
?