Standard built-ins

Generator.prototype.next()

Try the free JavaScript compiler

Resumes a suspended generator, optionally providing the result of its previous yield. The first input is ignored.

Formal Syntax & Structure

javascript syntaxjavascript
generator.next([value])

Parameters & Attributes

NameTypeDescription
valueanyInput or completion/exception value; optional.

Return Value

object

Iterator result object.

Working Example

Example Snippetjavascript
function* g(){yield 4;return 5;}const i=g();console.log(i.next().value,i.next().done);
JavaScript Reference