JavaScript Array findLast() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
ES2023

What You’ll Learn

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

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.

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.

📝 Syntax

General form of Array.prototype.findLast:

JavaScript
array.findLast(callback(element, index, array), thisArg)

Parameters

  • callback — predicate tested on each element from end to start.
  • element — current array item.
  • index — optional; position of the element.
  • array — optional; the array being searched.
  • thisArg — optional; value to use as this inside the callback.

Return value

  • The last element (tail-first) for which the callback is truthy.
  • undefined if no element passes.
  • Original array unchanged.

Common patterns

  • arr.findLast(n => n > 30) — last value above 30.
  • logs.findLast(l => l.level === "error") — most recent error.
  • arr.findLast(cb) ?? defaultVal — fallback when missing.

⚡ Quick Reference

GoalCode
Last matcharr.findLast(callback)
Search directionEnd → start
No matchundefined
Need index insteadfindLastIndex()
StandardES2023

📋 findLast() vs find() vs findLastIndex() vs reverse trick

Same predicate family, different direction and return type.

findLast
last value

Tail-first scan

find
first value

Head-first scan

findLastIndex
last index

Number or -1

reverse().find
legacy pattern

Copies array

Examples Gallery

Open DevTools Console (F12) or use Try-it labs. Example N maps to ?tryit=N.

📚 Getting Started

Tail-first search on numbers.

Example 1 — Last Number Greater Than 30

Both 40 and 50 pass; findLast returns 50.

JavaScript
const numbers = [10, 20, 30, 40, 50];

const result = numbers.findLast((n) => n > 30);

console.log(result);
// 50
Try It Yourself

How It Works

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)
Try It Yourself

How It Works

Values can match while indexes differ. Use findLastIndex() when you need the position of the tail match.

📈 Practical Patterns

Defaults, objects, and log-style data.

Example 3 — Provide a Default When Nothing Matches

Use ?? or || after findLast for friendly fallbacks.

JavaScript
const numbers = [10, 20, 30, 40, 50];

const result = numbers.findLast((n) => n > 100) ?? "No match found";

console.log(result);
// "No match found"
Try It Yourself

How It Works

?? only replaces null or undefined. Prefer it over || when 0 or "" could be valid matches.

Example 4 — Find the Last Active User

Return the most recent object whose status is "active".

JavaScript
const users = [
  { name: "Alice", status: "active" },
  { name: "Bob", status: "inactive" },
  { name: "Charlie", status: "active" }
];

const lastActive = users.findLast((u) => u.status === "active");

console.log(lastActive);
// { name: "Charlie", status: "active" }
Try It Yourself

How It Works

Alice is active but Charlie is the last active user in array order, so findLast picks Charlie.

Example 5 — Most Recent Error in a Log

Scan events from newest to oldest conceptually; get the last error entry.

JavaScript
const events = [
  { level: "info", msg: "Server started" },
  { level: "error", msg: "Disk full" },
  { level: "info", msg: "Retry scheduled" },
  { level: "error", msg: "Connection timeout" }
];

const lastError = events.findLast((e) => e.level === "error");

console.log(lastError.msg);
// "Connection timeout"
Try It Yourself

How It Works

Two errors exist; tail-first search returns the final one—ideal for “what went wrong most recently?” dashboards.

🚀 Common Use Cases

  • Audit logs — fetch the latest warning or error event.
  • Version history — last release marked as stable.
  • Form steps — last invalid field in tab order stored as array.
  • Game state — most recent power-up still active.
  • Chat threads — last message from a given user.
  • Analytics — final data point above a threshold.

🧠 How findLast() Runs

1

Start at length - 1

Begin at the last index and move backward.

Tail
2

Run callback

Test (element, index, array) at each step.

Predicate
3

Truthy?

Return that element and stop scanning.

Match
4

Reach index 0

If nothing passed, return undefined.

📝 Notes

  • Added in ES2023 alongside findLastIndex().
  • Returns undefined when no match—same as find().
  • Does not mutate or reverse the array (unlike spread + reverse tricks).
  • A stored undefined match is ambiguous vs not found—use findLastIndex if that matters.
  • Feature-detect with "findLast" in Array.prototype for older runtimes.
  • Polyfill or backward loop for environments without ES2023.

Browser & Runtime Support

Array.prototype.findLast() was added in ES2023. It is available in current evergreen browsers and Node.js 18+.

Baseline · ES2023

Array.prototype.findLast()

Supported in Chrome 97+, Firefox 104+, Safari 15.4+, Edge 97+, and Node 18+. Not available in Internet Explorer or very old mobile browsers.

92% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Array.findLast() Very Good

Bottom line: Safe for modern apps on current browser versions. Polyfill or use a reverse loop when you must support older clients.

Conclusion

The findLast() method completes the search toolkit: head-first with find(), tail-first with findLast(), and index variants when you need positions.

Reach for it whenever the last matching item matters—recent logs, final duplicates, or trailing state in ordered data.

💡 Best Practices

✅ Do

  • 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

Key Takeaways

Knowledge Unlocked

Five things to remember about Array.findLast()

Your foundation for tail-first array searches in ES2023.

5
Core concepts
🔃 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.

Continue to findLastIndex()

Learn how to get the index of the last matching element instead of the value.

findLastIndex() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful