Generator Function

noun

say it: “JEN-uh-ray-ter FUNK-shun” /ˈdʒɛnəreɪtər ˈfʌŋkʃən/

A JavaScript function marked with a star (function*) that hands out values one at a time with yield, pausing between them until the next value is asked for.

What is Generator Function in JavaScript?

Generator Function — A function declared with function* that can pause and yield several values.

function* countdown() {
    yield 3;
    yield 2;
    yield 1;
}

In a sentence

  • “A generator function replaced the whole iterator class with two loops and a yield.”
  • “The route's generator function fetched page 2 only when the driver reached it.”

Level: Freelancer · More JavaScript terms at this level

Updated