Equana

Docs/Arrays/filter
Back to Arrays

filter

Filter array elements by a predicate.

Syntax

filter(arr, fn) → Array of elements for which fn returns true

Backends

TypeScript

Description

Filter array elements by a predicate.

Parameters

NameDescription
arrInput array
fnPredicate function

Returns

Array of elements for which fn returns true

Examples

Try It
>> filter([1, 2, 3, 4], (x) -> x > 2)
[3, 4]

See Also