Lodash _.findIndex() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Like _.find, but returns the index of the first element for which predicate is truthy — not the element itself. Returns -1 when nothing matches. Part of Lodash Array since 1.1.0 (stable in 4.x — not deprecated).

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

Syntax

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

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

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

Library declarations
Lodash
_.findIndex(array, [predicate=_.identity], [fromIndex=0])

Parameters

ParameterDescription
arrayRequired. Collection to search
predicateOptional. Invoked as (value, index, array); default _.identity
fromIndexOptional. Where to start; default 0

Return Value

Return ValueDescription
*First matching index, or -1

Lodash Examples

Example 1 — Official: Function Predicate

Return the index of the first user named barney.

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

_.findIndex(users, function (o) { return o.user == "barney"; });
// → 0
Try It Yourself

How It Works

  1. Source. Three user objects; indexes 0 … 2.
  2. Test. Predicate checks o.user == "barney".
  3. Hit. Index 0 matches immediately.
  4. Return. Lodash stops and returns 0.

Example 2 — Official: Matches Object

Match a partial object with the _.matches shorthand.

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

_.findIndex(users, { user: "fred", active: false });
// → 1
Try It Yourself

How It Works

  1. Shorthand. An object uses Lodash _.matches rules.
  2. Skip. barney does not match both fields.
  3. Hit. fred matches → index 1.
  4. Stop. Later users are not checked.

Example 3 — Official: MatchesProperty Pair

Find the first user where active === false.

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

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

How It Works

  1. Pair form. ["active", false] means property equals value.
  2. First hit. barney.active is false → index 0.
  3. Early exit. fred would also match, but search already stopped.
  4. Use. Great for “first inactive” / “first with status X”.

Example 4 — Official: Property Shorthand

A string tests truthiness of that property.

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

_.findIndex(users, "active");
// → 2
Try It Yourself

How It Works

  1. Property iteratee. "active" reads each object’s active field.
  2. Falsy skip. false is falsy → indexes 0 and 1 skipped.
  3. Truthy hit. pebbles.active is true → index 2.
  4. Tip. Same idea as users.findIndex(u => u.active) in native JS.

Example 5 — No Match Returns -1

Always guard for “not found” before using the index.

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

_.findIndex(users, { user: "wilma" });
// → -1
Try It Yourself

How It Works

  1. Search. No user has user: "wilma".
  2. Scan ends. Every element fails the matches object.
  3. Result. Lodash returns -1 — not an error.
  4. Guard. Check idx !== -1 before users[idx].

Browser & Runtime Support

_.findIndex is a Lodash 4.x Array helper (since 1.1.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native Array.prototype.findIndex is also available in modern JS engines.

✓ Stable · Lodash 1.1.0+

_.findIndex()

Available in [email protected] full builds and the lodash/findIndex 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
_.findIndex Lodash 1.1.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import findIndex from "lodash/findIndex" for smaller builds — or native array.findIndex() when you do not need Lodash iteratee shorthands.

Frequently Asked Questions

_.findIndex(array, predicate, [fromIndex=0]) returns the index of the first element for which predicate is truthy. If nothing matches, it returns -1. It does not mutate the array.
_.find returns the matching element itself. _.findIndex returns that element’s index (or -1). Same iteratee shorthands work on both.
indexOf compares a single value with SameValueZero equality. findIndex runs a predicate (or Lodash iteratee) per element, so you can match objects by field or custom logic.
Search starts at that index. Negative values count from the end (like other Lodash array helpers). Matches before fromIndex are skipped.
Lodash returns -1 — same convention as native Array.prototype.findIndex.
Use import findIndex from "lodash/findIndex" or require("lodash/findIndex") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.findIndex.

Next: _.findLastIndex()

Search from the end and get the last matching index.

_.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.

10 people found this page helpful