Array.prototype.findLast()

findLast(callbackFn, thisArg)
Returns: undefined | element · Added in vES2023 · Updated March 13, 2026 · Array Methods
array find search es2023

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

Syntax

findLast(callbackFn)
findLast(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 findLast was called on.

Examples

Basic usage

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

const lastEven = nums.findLast(n => n % 2 === 0);
console.log(lastEven);
// 44

Finding 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 lastActive = users.findLast(u => u.active);
console.log(lastActive);
// { id: 4, name: "Diana", active: true }

When no match is found

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

const result = nums.findLast(n => n > 10);
console.log(result);
// undefined

Common Patterns

Getting the last item satisfying a condition

Use findLast when you need the most recent entry in a time-ordered array:

const events = [
  { type: "click", timestamp: 1700000000 },
  { type: "hover", timestamp: 1700000100 },
  { type: "click", timestamp: 1700000200 },
  { type: "scroll", timestamp: 1700000300 }
];

const lastClick = events.findLast(e => e.type === "click");
console.log(lastClick);
// { type: "click", timestamp: 1700000200 }

See Also