Skip to main content

findLastIndex()

findLastIndex<T>(predicate): (arr) => number

Returns the last index of the given array that satisfies the predicate. Returns -1 otherwise.

Type Parameters

T

T

The type of array elements.

Parameters

predicate

Predicate<T>

A predicate function to apply to each element of the array.

Returns

(arr): number

Parameters

arr

T[]

Returns

number

Remarks

pure function

Playground

findLastIndex(x => !(x & 1))([1, 2, 3, 4, 5]); // 3