Array.prototype.findLastIndex()

findLastIndex(callbackFn, thisArg)
Returns: number · Added in vES2023 · Updated March 13, 2026 · Array Methods
array find search es2023

findLastIndex() returns the index of the last element in an array that satisfies a testing function, or -1 if no element matches. It iterates from the end of the array toward the beginning.

Syntax

findLastIndex(callbackFn)
findLastIndex(callbackFn, thisArg)

Parameters

ParameterTypeDefaultDescription
callbackFnfunctionA function to execute for each element. Return true to signal a match.
thisArganyundefinedOptional. Value to use as this when executing callbackFn.

callbackFn Parameters

ParameterTypeDescription
elementanyThe current element being processed.
indexnumberThe index of the current element.
arrayarrayThe array that findLastIndex was called on.

Examples

Basic usage

const nums = [5, 12, 8, 130, 44];

const lastEvenIndex = nums.findLastIndex(n => n % 2 === 0);
console.log(lastEvenIndex);
// 4

Finding the index of the last matching object

const users = [
  { id: 1, name: "Alice", active: true },
  { id: 2, name: "Bob", active: false },
  { id: 3, name: "Charlie", active: true },
  { id: 4, name: "Diana", active: true }
];

const lastActiveIndex = users.findLastIndex(u => u.active);
console.log(lastActiveIndex);
// 3

When no match is found

const nums = [1, 3, 5, 7];

const index = nums.findLastIndex(n => n > 10);
console.log(index);
// -1

Common Patterns

Removing the last matching item

Combine findLastIndex with splice to remove the last matching element:

const items = ["a", "b", "c", "b", "d"];
const idx = items.findLastIndex(x => x === "b");

const removed = items.splice(idx, 1);
console.log(removed);
// ["b"]
console.log(items);
// ["a", "c", "b", "d"]

See Also