Underscore.js _.find() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Collection

Definition

Looks through each value in the list, returning the first one that passes a truth test (predicate), or undefined if no value passes. Returns as soon as it finds an acceptable element (official Underscore docs). Stable Collection helper — not deprecated.

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

Syntax

Call _.find. Start with this line.

Underscore
_.find(list, predicate, [context])
CallWhat it does
_.find(list, predicate, [context])Primary signature.
_.find(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.find(list, predicate, [context])

Parameters

ParameterDescription
listRequired. Array, array-like, or plain object
predicateRequired. Truth test; shorthands via iteratee
contextOptional. Bound as this in the predicate

Return Value

Return ValueDescription
*First match, or undefined

Underscore.js Examples

Example 1 — Official Docs First Even

Return the first even number from 1 through 6.

Underscore
var even = _.find([1, 2, 3, 4, 5, 6], function (num) {
  return num % 2 == 0;
});

even;
// → 2
Try It Yourself

How It Works

  1. 1. Odd → predicate is falsy; continue.
  2. 2. Even → predicate is truthy.
  3. Stop. Underscore returns 2 immediately.
  4. Docs sample. This is the official Underscore example.

Example 2 — Matcher & Property Shorthand

Find the first object that matches properties — no custom function.

Underscore
var books = [
  { title: "Emma", author: "Austen" },
  { title: "Hamlet", author: "Shakespeare" },
  { title: "Macbeth", author: "Shakespeare" }
];

_.find(books, { author: "Shakespeare" });
// → { title: "Hamlet", author: "Shakespeare" }

_.find(books, "title");
// → first book (truthy title)
Try It Yourself

How It Works

  1. Matcher. { author: "Shakespeare" } accepts the first matching object.
  2. Hamlet first. Macbeth is never reached.
  3. Property. "title" returns the first item with a truthy title.
  4. Related. For attrs-only search, see _.findWhere.

Example 3 — _.find vs _.filter

One value and early exit vs every match in a new array.

Underscore
function isEven(n) { return n % 2 == 0; }
var nums = [1, 2, 3, 4, 5, 6];

_.find(nums, isEven);     // → 2
_.filter(nums, isEven);   // → [2, 4, 6]
Try It Yourself

How It Works

  1. find. Returns the first even number and stops.
  2. filter. Builds an array of every even number.
  3. Cost. find can skip the rest of the list.
  4. Pick. Need one hit → find; need all → filter.

Example 4 — No Match, Identity & Alias

Misses return undefined; omit predicate for first truthy; _.detect matches _.find.

Underscore
_.find([1, 3, 5], function (n) { return n % 2 == 0; });
// → undefined

_.find([0, "", null, "ok", 2]);
// → "ok"   (identity = first truthy)

_.detect([1, 2, 3], function (n) { return n > 1; });
// → 2

_.detect === _.find;
// → true
Try It Yourself

How It Works

  1. Miss. No even number → undefined.
  2. Identity. Skips falsy values until "ok".
  3. Alias. _.detect is the same function as _.find.
  4. Guard. Check the result before reading properties.

Browser & Runtime Support

_.find (alias _.detect) ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.

✓ Stable · Underscore 1.x

_.find()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.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
_.find Underscore 1.x+

Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.find(list, predicate, [context]) returns the first value that passes the predicate, or undefined if none do. Official example: first even in [1..6] → 2.
Yes. detect is an alias of find. They are the same function.
_.find returns undefined. Always guard the result before using it.
_.find returns one value and stops early. _.filter returns a new array of every match and scans the whole list.
Yes. It returns as soon as it finds an acceptable element and does not traverse the rest of the list.
Yes. Pass an object matcher or a property name string. Underscore runs the predicate through iteratee.

Next: _.filter()

Keep every matching value in a new array — the all-matches cousin of _.find().

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