JavaScript (ES2026) reference · Array Methods

JavaScript Array findLast() Method

Return the last element that passes a test function, searching from the end, or undefined if none does.

JavaScript (ES2026) Since ES2023

Syntax

array.findLast(callbackFn, thisArg)

Parameters

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

Return value

The last matching element, or undefined.

Examples

Last matchTry it yourself
const temps = [12, 25, 18, 30, 15];
console.log(temps.findLast((t) => t > 20));

Output

30
Most recent errorTry it yourself
const log = [{ level: "info" }, { level: "error", msg: "disk" }, { level: "info" }];
console.log(log.findLast((e) => e.level === "error"));

Output

{ level: 'error', msg: 'disk' }

Version history

VersionChange
JavaScript ES2023Added