Lodash _.findLastIndex() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Like _.findIndex, but iterates from right to left. Returns the index of the last element predicate finds truthy for, else -1. Stable since Lodash 2.0.0 (4.x Array API).

Note: Native Array.prototype.findLastIndex (ES2023) is a callback-only twin — Lodash still wins when you need iteratee shorthands or older runtimes.

Syntax

Call _.findLastIndex on an array. Start with this line.

Lodash
_.findLastIndex(array, [predicate], [fromIndex])
CallWhat it does
_.findLastIndex(array, [predicate], [fromIndex])Primary signature.
_.findLastIndex(array)Call with an array argument.

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

Library declarations
Lodash
_.findLastIndex(array, [predicate], [fromIndex])

Parameters

ParameterDescription
arrayRequired. Collection to inspect
predicateOptional. Test per element; default _.identity
fromIndexOptional. Reverse-scan start; default last index

Return Value

Return ValueDescription
*Number index, or -1

Lodash Examples

Example 1 — Official: Callback

Find the last index where the user name is "pebbles".

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

_.findLastIndex(users, function (o) { return o.user == "pebbles"; });
// → 2
Try It Yourself

How It Works

  1. Source. Three user objects; indexes 0 … 2.
  2. Start at the end. Default fromIndex is 2.
  3. Test. pebbles matches on the first reverse step.
  4. Result. Index 2 — no need to keep scanning left.

Example 2 — Official: _.matches Shorthand

Pass a partial object; Lodash matches all listed properties.

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

_.findLastIndex(users, { user: "barney", active: true });
// → 0
Try It Yourself

How It Works

  1. Shorthand. Object form means “match these fields” (_.matches).
  2. Scan right → left. Index 2 and 1 fail the pair.
  3. Hit. Index 0 is barney with active: true.
  4. Tip. Same idea as _.findIndex, but the last match wins.

Example 3 — Official: _.matchesProperty

Find the last row where active is false.

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

_.findLastIndex(users, ["active", false]);
// → 2
Try It Yourself

How It Works

  1. Pair form. ["active", false] means property equals value.
  2. First reverse step. pebbles.active is false → match.
  3. Why not 1? Index 2 is farther right, so it wins as “last”.
  4. Use. Great for “most recent inactive” style queries.

Example 4 — Official: _.property Shorthand

A string predicate checks that property for truthiness.

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

_.findLastIndex(users, "active");
// → 0
Try It Yourself

How It Works

  1. Property name. "active" means “is active truthy?”.
  2. Skip falsy. Indexes 2 and 1 have active: false.
  3. Hit. Index 0 is the only (hence last) truthy active.
  4. Contrast. _.findIndex(users, "active") would also return 0 here — direction matters when duplicates exist.

Example 5 — Bound the Reverse Search

fromIndex sets where the reverse walk starts — matches to the right are skipped.

Lodash
_.findLastIndex([1, 2, 3, 2], function (x) { return x === 2; }, 2);
// → 1

// Full array without fromIndex would return 3 (rightmost 2)
Try It Yourself

How It Works

  1. Array. [1, 2, 3, 2] — twos at indexes 1 and 3.
  2. Start at 2. Reverse scan begins at value 3, not the last 2.
  3. Walk left. Index 2 fails; index 1 matches.
  4. Rule. A smaller fromIndex can hide later matches on purpose.

Browser & Runtime Support

_.findLastIndex is a Lodash 4.x Array helper (since 2.0.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 4.x

_.findLastIndex()

Available in [email protected] full builds and the lodash/findLastIndex modular import. Native Array.prototype.findLastIndex needs ES2023 (Chrome 97+, Firefox 104+, Safari 15.4+, Node 18+).

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
_.findLastIndex Lodash 4.x+

Bottom line: Safe for production once Lodash is loaded. Prefer import findLastIndex from "lodash/findLastIndex" for smaller bundles. On modern-only targets with callbacks only, native findLastIndex is fine.

Frequently Asked Questions

_.findLastIndex(array, predicate, fromIndex) returns the index of the last element for which predicate is truthy. It scans from right to left. If nothing matches, it returns -1.
No. It only reads the collection and returns a number (the index) or -1.
findIndex scans from the start and returns the first match. findLastIndex scans from the end (or from fromIndex) toward index 0 and returns the last match in that reverse walk.
fromIndex is where the reverse scan begins (default: array.length - 1). Matches to the right of that start are not considered.
Use import findLastIndex from "lodash/findLastIndex" or require("lodash/findLastIndex") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.findLastIndex.
Array.prototype.findLastIndex (ES2023) is callback-only. Lodash also accepts matches, matchesProperty, and property iteratee shorthands — useful on older runtimes or when you already use Lodash.

Next: _.flatten()

Unwrap one level of nested arrays into a flatter list.

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

10 people found this page helpful