Standard built-ins

Iterator.prototype.filter()

Try the free JavaScript compiler

Lazily yields values whose callback result is truthy. Callback receives value and index.

Formal Syntax & Structure

javascript syntaxjavascript
iterator.filter(predicate)

Parameters & Attributes

NameTypeDescription
predicatefunctionSelection callback.

Return Value

Iterator

Result of the operation.

Working Example

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