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