Language concepts

Iterator return() contract

Try the free JavaScript compiler

Optional protocol method for requesting completion and cleanup. An iterator result object is expected; custom implementations define their own cleanup and completion behavior.

Formal Syntax & Structure

javascript syntaxjavascript
iterator.return([value])

Parameters & Attributes

NameTypeDescription
valueanyOptional completion input.

Return Value

object

Iteration result.

Working Example

Example Snippetjavascript
const it={return(){return {done:true,value:5};}};console.log(it.return().done);
JavaScript Reference