Const
Returns the first element from the source iterable that satisfies an optional predicate.
Curried version of _first.
Element type produced by the source iterable.
Optional
Optional predicate receiving the current value and index; defaults to accepting every value.
The first element that matches the predicate.
Error - Thrown when the iterable is empty or no element satisfies pred.
pred
const value = _first(["red", "green", "blue"]);console.log(value); // "red" Copy
const value = _first(["red", "green", "blue"]);console.log(value); // "red"
or using the curried version:
const value = pipeInto( [1, 2, 3, 4], first((n) => n > 2));console.log(value); // 3 Copy
const value = pipeInto( [1, 2, 3, 4], first((n) => n > 2));console.log(value); // 3
Returns the first element from the source iterable that satisfies an optional predicate.
Curried version of _first.