Generators
- Can return (“yield”) multiple values, one after another, on-demand.
- They work great with
iterables
, allowing to create data streams with ease.
generator functions, function*
1 | function* generateSequence() { |
- When it (
generateSequence()
) is called, it doesn’t run its code. Instead it returns a “generator object” ([object Generator]
), to manage the execution.