Yielding

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.