jskatas.org Continuously Learn JavaScript. Your Way.

Generator: creation

There are many ways to create a generator

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

Generators can be created in multiple ways

  • the most common way is by adding * after function
  • as a function expression, by adding a * after function
  • inside an object by prefixing the function name with *
  • computed generator names, are just prefixed with a *
  • inside a class the same way

Links

Describes the `function*` declaration.