Great question. The reason we can spread an array with no index keys is because spread's implementation doesn't require that any index keys exist, unlike map. It blindly loops from 0 to 99, asks the array for array[index], and places whatever's returned in the new array.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think my question is out of the scope of the topic, but:
When we do:
Array(100);
If there are no index keys in the object representation of the array (the object is a vacuum), why we can spread it?? 🤯
const arr = [...Array(100)]
Thank you for this interesting post!
Salute from 🇦🇷!
Great question. The reason we can spread an array with no index keys is because spread's implementation doesn't require that any index keys exist, unlike map. It blindly loops from 0 to 99, asks the array for array[index], and places whatever's returned in the new array.