Standard built-ins

Iterator.prototype.find()

Try the free JavaScript compiler

Consumes until a predicate is truthy and returns that value; otherwise undefined. An early match closes the source.

Formal Syntax & Structure

javascript syntaxjavascript
iterator.find(predicate)

Parameters & Attributes

NameTypeDescription
predicatefunctionTest callback.

Return Value

any

Result of the operation.

Working Example

Example Snippetjavascript
console.log(JSON.stringify(Iterator.from([1,2,3]).find(x=>x>1)));
JavaScript Reference