Generators
ES6 brings us a new type of function, the generator function. Generators are a function that allows us to pause and resume execution. Generators exist in many other languages and are used mostly for control flow.
The syntax to create a generator is the same as a regular function, however we use the *
at the end of the function
keyword to indicate we are creating a generator.
Get hands-on with 1400+ tech skills courses.