What's the difference between Array(1)
and [...Array(1)]
? I was sure that both are equivalent until I saw that both behave differently regarding .map
:
console.log(Array(1).map(() => 1));
console.log([...Array(1)].map(() => 1));
Why do they behave differently even though both return [undefined]
?
console.log(Array(1));
console.log([...Array(1)]);