Multi-level arrays can be destructured with the same syntax. After demonstrating the syntax for nested array destructuring, Kyle spends a few minutes answering audience questions about default values and combining destructuring with the spread and gather operators.
- If we can destructure a single level of arrays,…we can obviously destructure nested arrays.…So I could, it might be the case,…that I would have, in this position,…an array that had 4, 5, 6 in a nested array, okay.…I'll spread that out so it's a little easier to read.…Okay, so now at the fourth position…we actually have an array with 4, 5, 6 in it.…What is args going to have in this particular case?…Tell me what the structure of args would be.…
- [Student 1] The array 4, 5, 6?…- No.…- [Student] An array where the first item is…the array 4, 5, 6.…- Args would be an array with one item in it,…the item in that one position in args…would be the array 4, 5, 6.…Okay, do you follow that?…All right, but what if I didn't want that?…What if I didn't want that thing as one big array,…what if I wanted 4, 5 and 6 individually addressable?…Well, I can do array destructuring…right inside of my pattern.…
A nested array destructuring that says,…make D the first one,…I don't care about the second one,…and make E the third one for example.…
This course was created by Frontend Masters. It was originally released on 01/10/2017. We're pleased to host this training in our library.
- The arrow function
- Arrow function variations
- Closures and explicit blocks
- Default values
- Using the gather and spread operators
- Dumping variables
- Concise properties and methods
- Symbols, iterators, and generators
- Optimizing codes for the reader
Skill Level Intermediate
1. Arrow Functions
2. Block Scope
3. Default Values and the Gather/Spread Operators
5. Template Strings
6. Symbols, Iterators, and Generators
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.