Skip to content

Array.findLastIndex method

Array › findLastIndex

Official

Returns the index of the last element that satisfies the provided predicate.

Signature:

findLastIndex(predicate: (value: T) => boolean): number

Parameters:

Parameter Type Description
predicate (value: T) => boolean The predicate to test each element.

Returns: numberThe index of the last element that satisfies the predicate, or -1 if no such element is found.

Since: 1.4.4

Example:

console.log([1, 2, 3, 2, 1].findLastIndex(x => x === 2)); // 3
console.log([1, 2, 3, 2, 1].findLastIndex(x => x === 4)); // -1