Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
So the difference is holes in an array versus undefined elements. And that happens due to this:
John Hardy
@jhlagado
The difference is that the spread operation creates an iterator which maps over all the elements. slice() operates at a lower level. twitter.com/laurieontech/s…
21:53 PM - 24 Jul 2019
Laurie
@laurieontech
Hey, @bitandbang, any idea what the underlying reason for this difference is? I've been scouring the docs and can't seem to find anything that implies the two results would be any different.
https://t.co/aCRfd5jblA
In [...arr], what the spread operator conceptually does is to get an iterator from arr (like for (const item of arr) { ... }), and the iterator returns undefined when it encounters a hole, rather than skipping it
So this is what I see
But no docs are telling me why that's the case. Still searching because I genuinely want to know!
So the difference is holes in an array versus undefined elements. And that happens due to this:
Also explained this way:
Awesome! Thank you!