[9,2,3,4,5] filter (value, index) -> (value > 2)
filter
filter(Array<T>, (item: T, index: Number) -> Boolean): Array<T>
Iterates over an array and applies an expression that returns matching values.
The expression must return true
or false
. If the expression returns true
for a value or index in the array, the value gets captured in the output array.
If it returns false
for a value or index in the array, that item gets
filtered out of the output. If there are no matches, the output array will
be empty.
Parameters
Name | Description |
---|---|
|
The array to filter. |
|
Boolean expression that selects an |