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
| Parameter | Description |
|---|---|
callbackFn |
Called for each element with (element, index, array). |
Return value
The last matching element, or undefined.
Examples
const temps = [12, 25, 18, 30, 15];
console.log(temps.findLast((t) => t > 20));
Output
30
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
| Version | Change |
|---|---|
| JavaScript ES2023 | Added |
Related
array.find()· Return the first element that passes a test function, or undefined if none does.array.findLastIndex()· Return the index of the last element that passes a test function, or -1 if none does.- JavaScript Arrays · tutorial
- JavaScript Array Methods · tutorial