JavaScript (ES2026) reference · Array Methods

JavaScript Array findLastIndex() Method

Return the index of the last element that passes a test function, or -1 if none does.

JavaScript (ES2026) Since ES2023

Syntax

array.findLastIndex(callbackFn, thisArg)

Parameters

ParameterDescription
callbackFn Called for each element with (element, index, array).

Return value

An index, or -1.

Examples

Last match's indexTry it yourself
console.log([1, 8, 3, 9, 2].findLastIndex((n) => n > 5));

Output

3
No matchTry it yourself
console.log(["a", "b"].findLastIndex((x) => x === "z"));

Output

-1

Version history

VersionChange
JavaScript ES2023Added