Kyle walks through the solution to exercise 2. The solution is located in the file ex2-fixed.js.
(dojo music)…- So let's talk about solution for exercise two.…We have the a1 and the a2 arrays,…if you we want to pass those in…we can just spread out a1 and a2.…And then we have the foo function which we want to define,…we want it to return something,…but we're gonna declare the parameters in such a way…that it does the work for us.…So we basically want to account for,…we want to keep the first one,…but then we got two that we don't.…
We don't care about the value four or the value six…so essentially those are ones that we're gonna throw away.…So we can name 'em y and z or we can name 'em something else…that indicates that we're going to ignore them, right?…We could call them ignored one and ignored two…if we wanted to,…but then everything else we do care about…so we can say ...rest or args…or whatever you wanna call it.…So now we have an x value and we have the rest value…and we wanna put those two together…so we can say return,…make ourselves an array that includes x and everything else.…
Now the foo name here can throw people off…
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.