Lodash _.findLast() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Collection

Definition

Like _.find, but iterates right to left. Returns the last element that passes your predicate — or undefined if none match. Part of Lodash 4.x Collection.

Pass the required arguments shown below. Lodash Collection helpers usually return a new value — check whether the source is mutated.

Syntax

Call _.findLast on a collection. Start with this line.

Lodash
_.findLast(collection, [predicate], [fromIndex])
CallWhat it does
_.findLast(collection, [predicate], [fromIndex])Primary signature.
_.findLast(collection)Call with a collection argument.

Prefer import findLast from "lodash/findLast" when you want a smaller bundle.

Library declarations
Lodash
_.findLast(collection, [predicate], [fromIndex])

Parameters

ParameterDescription
collectionRequired. Array or object to inspect
predicateOptional. Test per element; default _.identity
fromIndexOptional. Start of reverse scan (arrays); default length - 1

Return Value

Return ValueDescription
*Matched element, else undefined

Lodash Examples

Example 1 — Official: Last Odd Number

Scan [1, 2, 3, 4] from the end; keep the last odd value.

Lodash
_.findLast([1, 2, 3, 4], function (n) {
  return n % 2 == 1;
});
// → 3
Try It Yourself

How It Works

  1. Source. Four numbers; indexes 0 … 3.
  2. Start at the end. Check 4 — even, skip.
  3. Next left. Check 3 — odd, truthy → return it.
  4. Stop early. No need to check 2 or 1.

Example 2 — Object Matcher Shorthand

Pick the last user whose active flag is true.

Lodash
var users = [
  { user: "barney", active: true },
  { user: "fred", active: false },
  { user: "pebbles", active: true }
];

_.findLast(users, { active: true });
// → { user: "pebbles", active: true }
Try It Yourself

How It Works

  1. Matcher. { active: true } means “object must match these fields.”
  2. Reverse scan. Start at pebbles — active → match.
  3. Return value. The whole object is returned, not just the flag.
  4. vs find. _.find(users, { active: true }) would return barney.

Example 3 — Bound Scan with fromIndex

Start the reverse search earlier so later elements are ignored.

Lodash
_.findLast([1, 2, 3, 4], function (n) {
  return n % 2 == 1;
}, 2);
// → 3

_.findLast([1, 2, 3, 4], function (n) {
  return n % 2 == 1;
}, 1);
// → 1
Try It Yourself

How It Works

  1. Default. Without fromIndex, the scan starts at the last index.
  2. fromIndex 2. Starts at 3 — odd → returns 3 (never looks at 4).
  3. fromIndex 1. Starts at 2 (even), then 1 (odd) → returns 1.
  4. Use. Skip a “newer” tail when you only care about an earlier window.

Example 4 — No Match → undefined

When every element fails the test, Lodash returns undefined.

Lodash
_.findLast([2, 4, 6, 8], function (n) {
  return n % 2 == 1;
});
// → undefined
Try It Yourself

How It Works

  1. All even. No odd numbers exist.
  2. Full reverse pass. Every check is falsy.
  3. Sentinel. Result is undefined, not null or -1.
  4. Guard. Use if (result !== undefined) before reading fields.

Example 5 — _.find vs _.findLast

Same predicate, opposite direction — different winners when duplicates exist.

Lodash
var nums = [5, 8, 12, 15, 18];

_.find(nums, function (n) { return n % 2 === 0; });
// → 8

_.findLast(nums, function (n) { return n % 2 === 0; });
// → 18
Try It Yourself

How It Works

  1. Even values. 8, 12, and 18 all pass.
  2. find. Starts at 5, hits 8 first → returns 8.
  3. findLast. Starts at 18 — already even → returns 18.
  4. Pick by intent. “Earliest” → _.find; “latest” → _.findLast.

Browser & Runtime Support

_.findLast is a Lodash 4.x Collection helper. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native Array.prototype.findLast is ES2023 and separate.

✓ Stable · Lodash 4.x

_.findLast()

Available in [email protected] full builds and the lodash/findLast modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
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
_.findLast Lodash 4.x+

Bottom line: Safe for production once Lodash is loaded. Prefer import findLast from "lodash/findLast" for smaller builds. For array-only modern JS without Lodash, see native Array.findLast.

Frequently Asked Questions

_.findLast(collection, predicate, fromIndex) returns the last element that satisfies the predicate. On arrays it scans from right to left. If nothing matches, it returns undefined.
No. It only reads elements until a match is found. The source array or object is left unchanged.
_.find returns the first match (left-to-right). _.findLast returns the last match (right-to-left). Same iteratee shorthands; only direction changes.
For array-like collections, fromIndex is where the reverse scan starts (default: collection.length - 1). Use it to ignore elements after that index.
_.findLast returns undefined — same sentinel as _.find. Guard the result before reading properties.
Native Array.findLast (ES2023) is fine for modern array-only code. Prefer _.findLast when you need Lodash iteratee shorthands, objects as collections, or older runtimes via Lodash.

Next: _.flatMap()

Map each item and flatten one level in a single pass.

_.flatMap() 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.

8 people found this page helpful