Yielding is a shift of control between a generator and its caller. It is achieved by the yield expression, which can optionally designate a value to its right side (the yielded value). It is only valid to use a yield statement within a generator function:

function* makeSomeNumbers() {  yield 645;  yield 422;  yield 789;}const iterable = makeSomeNumbers();iterable.next(); // => {value: 645, done: false}iterable.next(); // => {value: 422, done: false}iterable.next(); // => {value: 789, done: false}

If you yield without a value (yield;) then the result will be the same as yielding undefined

Yielding will force any subsequent calls to the generator function to continue evaluation from the point of yield (as if the yield hadn't occurred). ...

Get Clean Code in JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.