The question is, what is the difference between Array(5)
and [...Array(5)]
See below variable c
and d
is the same yet .map
treats it differently.
let a = [...Array(5)].map((k,i)=>{
console.log("Hello");
return i;
})
console.log(a);
let b = Array(5).map((k,i)=>{
console.log("Hello");
return i;
})
console.log(b);
let c = Array(5)
let d = [...Array(5)]
console.log(c) // c and d seem to be the same
console.log(d)