Learn how to use the ellipsis operator with the spread syntax, which allows you to expand arrays into multiple variables.
- [Instructor] The other use for the ellipsis operator…in ES6 is with spread.…In some ways, this is the opposite of Rest parameters…which essentially gathers values into a single argument.…The spread syntax is used to take an iterable object…such as an array and assign it to multiple variables.…This can happen when passing an argument to a function…or when applying values into an array.…Let's look at how to use the spread syntax in a function.…Here we have a constructor function…that takes three arguments.…
Then we have three potential values for those arguments…stored in an array.…When calling the constructor function in ES5,…we would have to individually reference each array element…via its index.…This is obviously pretty repetitive and with ES6,…it's a perfect use case for the spread syntax.…Because all the values of the array are stored…in the same order as the constructor arguments,…we can just use the array variable as an argument…to the constructor function…and apply the spread operator to it.…
This will spread the array into three arguments…
- Using arrow functions
- Using default parameters
- Reviewing the class structure in ES6
- Assigning variables with let and const
- Array destructuring and object destructuring
- Replacing callbacks with promises
- Keeping values unique with Set
- Dropping the prototype with Map
- Working with generators
- Using yield with arguments
Skill Level Intermediate
Node.js: Test-Driven Developmentwith Alexander Zanfir33m 13s Intermediate
Learning NPM the Node Package Manager (2015)with Ray Villalobos35m 10s Intermediate
React.js: Building an Interfacewith Ray Villalobos1h 21m Intermediate
3. Promises and Collections
4. Iterators and Generators
Next steps1m 41s
- 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.