Rest syntax in Array literals | Javascript In depth, from spec
Channel: bendtherules
Date: 2020-07-27

We use array literals and rest syntax (like `[a, b, ...arr]`) all the time to create and manipulate arrays. But we often don't know the exact details of how this syntaxes work in Javascript.  

So, today we will answer these in details - 

1. How does array literal create a array, step-by-step?
2. How rest syntax (...arr) consumes values from a existing array or iterable?
3. How does in-built Array iterator work? (with polyfill)

0:00 Start
0:40 Quiz about rest syntax
1:18 Quiz answer + explanation
2:17 Basic array literal - [10, 20]
4:20 Array with holes - [10, , 20]
5:49 Rest in array literal - [...arr]
6:38 Iterator protocol
7:53 How ... consumes iterators
9:53 Inbuilt array iterator - case 1
11:15 Inbuilt array iterator - case 2
13:25 How does inbuilt Array Iterator work? + code
20:10 Outro

#BitsOfEcmascript