Practical Applications

infinite sequences, code that is evaluated lazily and asynchronous programming

You now know everything required to be able to write generator functions. This is one of the hardest topics in ES6, so you will get a chance to solve more exercises than usual.

After practicing the foundations, you will find out how to use generators in practice to:

  • define infinite sequences (exercise 5),
  • create code that is evaluated lazily (exercise 6).

For the sake of completeness, it is worth mentioning that generators can be used for asynchronous programming. Running asynchronous code is outside the scope of this lesson. We will use promises for handling asynchronous code.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.