Lodash _.find() method

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

What you’ll learn

  • How _.find(collection, predicate, fromIndex) returns the first match—or undefined.
  • When optional fromIndex helps resume scans without slicing arrays manually.
  • How this differs from _.filter (all matches) and when to prefer native Array.prototype.find.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Review _.filter() if you want every matching row—find targets only the first hit.

  • You understand optional chaining or guards for possibly undefined results.
  • You can open Try-it labs or run snippets locally.

Overview

_.find answers “give me one representative row that qualifies”—authorization lookups, config picking, or locating the first failing validator input without scanning the tail unless necessary.

First match wins

Traversal stops immediately—ideal when duplicates exist but any valid exemplar suffices.

Indexed shortcuts

Arrays honor fromIndex so you can paginate or resume scans cheaply.

Unified iteratees

Property paths and matcher objects behave just like on filter or map.

Syntax

javascript
_.find(collection, predicate, fromIndex)
  • collection: array, array-like, or plain object Lodash can iterate.
  • predicate: invoked as (value, index|key, collection); first truthy predicate result yields that value.
  • fromIndex: optional start offset for array-like collections (defaults to 0).
  • Returns: the first matching element/value, or undefined if none qualify.
1

Locate a record by partial match

Matcher objects behave like shorthand predicates—perfect for primary-key style lookups in cached lists.

javascript
import find from "lodash/find";

find(
  [
    { id: "u1", tier: "free" },
    { id: "u2", tier: "pro" },
    { id: "u3", tier: "team" }
  ],
  { id: "u2" }
);
// → { id: "u2", tier: "pro" }
Try it Yourself
2

Resume scanning with fromIndex

Skip leading elements when you already ruled them out—no intermediate slice required.

javascript
import find from "lodash/find";

find([2, 4, 6, 9, 10], (n) => n % 2 === 1, 3);
// → 9 (odd after index 3)
Try it Yourself
3

First matching value in an object

Objects iterate values in Lodash order—you receive the actual value, not its key, when something matches.

javascript
import find from "lodash/find";

find(
  { east: { score: 12 }, west: { score: 44 }, south: { score: 9 } },
  (region) => region.score >= 40
);
// → { score: 44 }
Try it Yourself

📋 _.find vs filter, findLast, native find

APIOutcomeBest when
_.find(collection, predicate)First match or undefinedYou only need one qualifying element
_.filter(collection, predicate)Array of all matchesYou need every passing row
_.findLast(collection, predicate)Last match or undefinedTrailing occurrences matter most
array.find(predicate)First match or undefinedArrays only—no object collections

Pitfalls to avoid

Undefined

undefined is ambiguous

Both “missing row” and “field literally undefined” need different guards—structure APIs accordingly.

Order

Object iteration order

Which match counts as “first” follows Lodash enumeration—not always insertion order for exotic keys.

Dupes

Arbitrary winner

When duplicates exist and stability matters, sort upstream or switch to filter.

❓ FAQ

undefined—not null—so explicit checks keep edge cases obvious.
No. Lodash reads elements until a match surfaces; sources stay unchanged.
find returns the first matching value (or undefined); filter returns an array of every match.
Yes for array-like collections—the search begins at that offset, mirroring other Lodash indexed helpers.
Yes—it walks enumerable values and returns the first value whose predicate passes.

Summary

Did you know?

_.find stops at the first truthy predicate hit—unlike _.filter, which always walks the whole collection to gather every match. Use find when you only care whether a representative row exists.

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