Language concepts

yield expression

Try the free JavaScript compiler

Suspends a generator and makes a value available to its consumer. On resumption, the expression evaluates to the input supplied by the next call.

Formal Syntax & Structure

javascript syntaxjavascript
yield expression

Working Example

Example Snippetjavascript
function* g(){const x=yield 1;yield x;}const i=g();i.next();console.log(i.next(8).value);
JavaScript Reference