Returns undefined if no element satisfies condition. This differs from the built-in Array.findLastIndex(), but is more consistent with other functions in this library.
undefined
condition
Array.findLastIndex()
import * as A from "flurp/array";import * as N from "flurp/number";const lastPositiveIndex = A.findLastIndex(N.isPositive);lastPositiveIndex([-3, -4, 1, -5, 8, -2]); // 4lastPositiveIndex([-3, -4, -1, -5, -8, -2]); // undefined
Remarks
Returns
undefined
if no element satisfiescondition
. This differs from the built-inArray.findLastIndex()
, but is more consistent with other functions in this library.Example