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
| Parameter | Description |
|---|---|
callbackFn |
Called for each element with (element, index, array). |
Return value
An index, or -1.
Examples
console.log([1, 8, 3, 9, 2].findLastIndex((n) => n > 5));
Output
3
console.log(["a", "b"].findLastIndex((x) => x === "z"));
Output
-1
Version history
| Version | Change |
|---|---|
| JavaScript ES2023 | Added |
Related
array.findIndex()· Return the index of the first element that passes a test function, or -1 if none does.array.lastIndexOf()· Return the last index at which a value is found (using ===), searching backwards, or -1 if it isn't there.array.findLast()· Return the last element that passes a test function, searching from the end, or undefined if none does.- JavaScript Arrays · tutorial
- JavaScript Array Methods · tutorial