Generators provide some syntactic assistance to the process of writing iterators. Learn how to write generator functions and use the yield keyword in order to build recurring functionality into your programs.
- [Instructor] Generators are a new type of function … that allow us to pause functions … in the middle of execution to be resumed later. … You know you're looking at a generator … when you see an asterisk … immediately following the function keyword. … So let's go ahead and create a generator here. … We're going to create a generator called director. … So the director generator function … is going to do a countdown for us, basically. … Within a generator, … we can hit pause by using the yield keyword, … and this can be used numerous times … within the same function. … Now, inside of the director function, … we're going to use four yield statements … for a director counting down until the camera is rolling. … Now, let's set a variable that calls the director function. … And what we'll do here is we'll console.log … to retrieve the values from the director generator. … So if I call this method called .next, … the next function is going to return an object … that contains the value and done. …
This course was created by Eve Porcello. We are pleased to offer this training in our library.
- What is ECMAScript?
- Writing and searching strings
- Writing maps
- Destructuring arrays
- Searching arrays
- Creating objects
- Destructuring objects
- Iterating with the for/of loop
- Getting and setting class values
- Using ECMAScript functions
- Building and returning promises
- Using async/await syntax
Skill Level Intermediate
1. What Is ECMAScript?
What is ECMAScript?1m 44s
2. ECMAScript Variables and Data Structures
3. Arrays and Array Methods
Destructuring arrays1m 34s
4. ECMAScript Objects
5. ECMAScript Functions
- 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.