Both array and object destructuring can occur in a function’s parameter list. Kyle works through a few examples where destructuring in a parameter list can be useful. He also explains how it works with default parameters.
(Asian music)…- Everything I just talked to you about…with array destructuring and object destructuring…in the declarator sense…and in the straight-up assignment sense.…Every bit of that…is exactly and identically applicable…to function parameters.…We can do array and object destructuring…inside of our function parameter list.…So for example,…I could say that I am expecting to receive an array…in the first argument position,…the first parameter position of foo,…but I want to go ahead and break that thing down,…so I'm going to do an array destructuring…to say that the first item should be A,…the second one should be B,…and the third one should be C.…
So if I print it out,…console dot log,…A, B and C.…If I pass in foo…of 1,2,3,…what's going to to happen?…Think about your processing.…- [Student] It's not an array so it won't destructure?…- You have a number value…the number one,…that you then try to access a property on it.…
So you try to say one, bracket, zero essentially.…Have you ever tried that before?…Do you know if that works or if that's an error?…
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?
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.