Lodash _.findLast() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.findLast(collection, predicate, fromIndex) selects the trailing match instead of the leading one.
  • Why audit logs, revision histories, and stacked events often want “last winner” semantics.
  • How this differs from _.find and from array-only _.findLastIndex.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Read _.find() first—the iteratee contract is identical; only traversal direction changes.

  • You can reason about reverse-order scans on arrays.
  • You can open Try-it labs or run snippets locally.

Overview

_.findLast prefers the newest duplicate, the final flagged row, or the tail-most anomaly—without reversing arrays manually or tracking indices yourself.

Right-to-left arrays

Arrays inspect from the last index backward until something passes—cheap stop once found.

Latest semantics

Model timelines where the final qualifying entry defines current state.

Same iteratees

Reuse matcher objects and path shorthands from map, filter, or find.

Syntax

javascript
_.findLast(collection, predicate, fromIndex)
  • collection: array, array-like, or plain object Lodash can iterate.
  • predicate: invoked as (value, index|key, collection); truthy keeps the candidate in play while scanning backward.
  • fromIndex: optional bound for array-like collections where the reverse scan begins.
  • Returns: the last matching element/value, or undefined if none qualify.
1

Last passing number in an array

Several values may satisfy the rule—findLast keeps the right-most hit.

javascript
import findLast from "lodash/findLast";

findLast([5, 8, 12, 15, 18], (n) => n % 2 === 0);
// → 18
Try it Yourself
2

Last record matching a partial object

Duplicate tiers or statuses appear often—pick the final occurrence without reversing manually.

javascript
import findLast from "lodash/findLast";

findLast(
  [
    { id: 1, tier: "pro", seats: 2 },
    { id: 2, tier: "team", seats: 10 },
    { id: 3, tier: "pro", seats: 5 }
  ],
  { tier: "pro" }
);
// → { id: 3, tier: "pro", seats: 5 }
Try it Yourself
3

Last qualifying value in an object collection

Plain-object traversal still yields a single winning value—the last one Lodash encounters while scanning backward through its sequence.

javascript
import findLast from "lodash/findLast";

findLast(
  { a: { v: 1 }, b: { v: 30 }, c: { v: 7 }, d: { v: 25 } },
  (item) => item.v > 10
);
// → { v: 25 }
Try it Yourself

📋 _.findLast vs find, findLastIndex, native findLast

APIOutcomeBest when
_.findLast(collection, predicate)Last matching valueObjects or arrays—Lodash iteratees
_.find(collection, predicate)First matching valueEarliest occurrence suffices
_.findLastIndex(array, predicate)Last matching indexYou need the position, not the element
array.findLast(predicate)Last matching valueModern JS arrays without Lodash shorthands

Pitfalls to avoid

Objects

“Last” depends on enumeration

Do not assume insertion order for all key shapes—verify Lodash iteration matches your mental model.

Index

Mixing up element vs index APIs

Grab findLastIndex when downstream code slices by numeric offset.

Dupes

Unstable duplicates

If duplicates are unordered noise, sort or normalize before relying on tail picks.

❓ FAQ

undefined—the same sentinel as _.find when no element satisfies the predicate.
No. Lodash walks elements (from the end for arrays) until a match is found; inputs stay unchanged.
find returns the first qualifying element; findLast returns the last qualifying element for the collection's iteration order.
For array-like values it bounds where the reverse scan begins—consult Lodash docs for the exact index semantics on your version.
Yes—it evaluates values and returns the last match according to Lodash's enumeration of that object.

Summary

  • Purpose: _.findLast(collection, predicate, fromIndex) returns the last element matching the predicate.
  • Contrast: switch to _.find for head-first scans or _.findLastIndex for trailing indices.
  • Next: Lodash _.flatMap(), Lodash _.find() (previous), or collection hub.
Did you know?

Need the index of the last match in an array instead of the element? Use _.findLastIndex() in the array chapter—it pairs mentally with _.findLast the same way findIndex pairs with find.

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