The findLast() method returns the last element that passes your test, searching from the end of the array. Added in ES2023, it mirrors find() but scans tail-first. This tutorial covers syntax, five examples, defaults when nothing matches, and comparisons with find() and findLastIndex().
01
Syntax
findLast(cb)
02
Last match
Tail-first
03
No match
undefined
04
vs find()
End vs start
05
Objects OK
Custom test
06
ES2023
Modern JS
Fundamentals
Introduction
find() stops at the first match from the front. But what if you care about the most recent log entry, the last failed test, or the final item in a list that meets a rule? That is where findLast() fits.
It walks the array from the last index toward zero and returns the first element (in reverse order) whose callback returns a truthy value.
Concept
Understanding the findLast() Method
array.findLast(callback) uses the same callback signature as find(): (element, index, array). The difference is search direction—evaluation begins at length - 1 and moves backward.
When multiple elements pass the test, findLast() returns the one closest to the end of the array.
💡
Beginner Tip
Before ES2023, developers often used [...arr].reverse().find(cb) or a backward for loop. findLast() does the same job without mutating or copying the array.
The search starts at index 4 (50), which passes the test, so findLast returns 50 immediately. Index 3 (40) also passes but is never considered because tail-first search stops at the first match from the end.
Example 2 — find() vs findLast() on Duplicates
When several values match, direction decides the winner.
JavaScript
const scores = [85, 90, 75, 90, 60];
const firstHigh = scores.find((s) => s >= 90);
const lastHigh = scores.findLast((s) => s >= 90);
console.log(firstHigh);
// 90 (index 1)
console.log(lastHigh);
// 90 (index 3 — same value, different position)
Use findLast for the most recent match in ordered data
Provide defaults with ?? when no match is possible
Feature-detect before use in mixed environments
Pair with findLastIndex when you need the slot
Keep callbacks pure and fast
❌ Don’t
Confuse it with find() on duplicate-heavy arrays
Assume support in legacy browsers without checking
Use [...arr].reverse().find() when findLast exists
Forget undefined means not found
Mutate the array during the search callback
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Array.findLast()
Your foundation for tail-first array searches in ES2023.
5
Core concepts
📝01
Syntax
arr.findLast(cb)
API
🔃02
Tail-first
End → start.
Direction
🔎03
Last match
One element.
Result
❓04
No match
undefined
Guard
📅05
ES2023
Modern JS.
Standard
❓ Frequently Asked Questions
findLast() returns the last element in an array for which the callback returns a truthy value. It searches from the end toward the start. If no element matches, it returns undefined.
No. findLast() only reads elements through your callback. The original array is unchanged.
find() returns the first match scanning from index 0. findLast() returns the last match scanning from the end. On arrays with duplicate matches, they often return different elements.
It returns undefined, the same as find(). Use a fallback with || or nullish coalescing when you need a default.
findLast() returns the matching element. findLastIndex() returns its index (or -1). They share the same tail-first search direction.
findLast() is an ES2023 feature. It works in Chrome 97+, Firefox 104+, Safari 15.4+, Edge 97+, and Node 18+. Older environments need a polyfill or a manual reverse loop.
Did you know?
ES2023 added four tail-search methods together: findLast, findLastIndex, and the same pair on TypedArray. They remove the need to clone and reverse arrays just to search from the end.