jskatas.org Continuously Learn JavaScript. Your Way.

Generator: send function to a generator

By calling next() with a function, you can pass it to the 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.

Pass a function to a generator

  • the generator can receive a function as a value
  • pass a function to the iterator, which calls it
  • nesting yielded function calls