Returns the last element of the source iterable that satisfies the optional predicate, or undefined when none match.
undefined
Element type produced by the source iterable.
Source iterable to enumerate.
Predicate receiving each element and its index; the most recent truthy match is returned.
The last matching element, or undefined when no match exists.
Error Rethrows any error thrown by pred.
pred
const result = _lastOrDefault([1, 2, 3, 4], (value) => value > 4);console.log(result); // undefined Copy
const result = _lastOrDefault([1, 2, 3, 4], (value) => value > 4);console.log(result); // undefined
or using the curried version:
const result = pipeInto( [1, 2, 3, 4], lastOrDefault((value) => value % 2 === 0));console.log(result); // 4 Copy
const result = pipeInto( [1, 2, 3, 4], lastOrDefault((value) => value % 2 === 0));console.log(result); // 4
Returns the last element of the source iterable that satisfies the optional predicate, or
undefinedwhen none match.