Kyle highlights a few other use cases for the gather and spread operators. He also briefly explains that only data types that have an iterator can be spread. Kyle covers iterators later in the course.
(flute music)…- There are other places where,…besides parameter lists,…where this gather and spread can be used.…So, another place is within the context of array literals.…So let's say I have x is equal to array one, two, three,…and y is four and five,…and what I'd like is…to define a z, which includes the content,…includes a value plus the contents of x,…plus the contents of y plus another value.…
So I would do that by saying array of zero, .concat,…and I'd say x, y, and then another array…with some other value like the value six, for example.…Anybody ever used array concat before?…So now, z would have zero, one, two,…three, four, five, six in it, okay?…So, any place where I find myself using the .apply…and the .slice, those are places where the 'dot, dot, dot'…helps, but also places where I see myself doing .concat,…that's another one of those smells, like, oh maybe this is…a place where 'dot, dot, dot' can help me, okay?…So this is the imperative form of doing that,…the declarative form,…we start out again with the same array:…
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.