Finds the index of the last element in the source array that satisfies the provided predicate function.
Returns -1 if no element satisfies the predicate.
-1
const findLastPositiveIndex = findLastIndex((x: number) => x > 0);const a = findLastPositiveIndex([1, 2, 3]); // 2const b = findLastPositiveIndex([-1, 0, -2]); // -1 Copy
const findLastPositiveIndex = findLastIndex((x: number) => x > 0);const a = findLastPositiveIndex([1, 2, 3]); // 2const b = findLastPositiveIndex([-1, 0, -2]); // -1
Finds the index of the last element in the source array that satisfies the provided predicate function.
Returns
-1
if no element satisfies the predicate.Example