Lodash _.minBy() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Math

Definition

Like _.min, except it accepts an iteratee that ranks each element. Returns the original element with the lowest score. Part of Lodash Math since 4.0.0 (stable — not deprecated). The iteratee is called with one argument: (value).

Pass the numbers or collection shown below. Check the return value before you chain another math helper.

Syntax

Call _.minBy. Start with this line.

Lodash
_.minBy(array, iteratee)
CallWhat it does
_.minBy(array, iteratee)Primary signature.

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

Library declarations
Lodash
_.minBy(array, iteratee)

Parameters

ParameterDescription
arrayRequired. Array to iterate over
iterateeOptional. Function or property path; invoked as (value)

Return Value

Return ValueDescription
*The minimum element, or undefined if empty/falsey

Lodash Examples

Example 1 — Official: Function Iteratee

Return the field used to rank each object.

Lodash
var objects = [{ n: 1 }, { n: 2 }];

console.log(_.minBy(objects, function (o) {
  return o.n;
})); // { n: 1 }
Try It Yourself

How It Works

  1. Input. Official sample: two objects with n.
  2. Iteratee. Function returns o.n for ranking.
  3. Compare. 1 is less than 2.
  4. Result. The whole first object — not just 1.

Example 2 — Official: Property Shorthand

Pass the field name as a string — same result.

Lodash
var objects = [{ n: 1 }, { n: 2 }];

console.log(_.minBy(objects, "n")); // { n: 1 }
Try It Yourself

How It Works

  1. Shorthand. 'n' is the _.property iteratee.
  2. Pull. Lodash reads o.n for each object.
  3. Winner. Same element: { n: 1 }.
  4. When. Prefer this for a simple field path.

Example 3 — Nested Property Path

Dotted paths drill into nested objects.

Lodash
var products = [
  { name: "A", price: { base: 30 } },
  { name: "B", price: { base: 10 } },
  { name: "C", price: { base: 20 } }
];

console.log(_.minBy(products, "price.base"));
// → { name: "B", price: { base: 10 } }
Try It Yourself

How It Works

  1. Path. 'price.base' reads the nested number.
  2. Scores. 30, 10, 20.
  3. Min. 10 wins → product B.
  4. Tip. Use a function when ranking needs a formula.

Example 4 — Empty or Falsey Input

Like _.min, there is no minimum to return.

Lodash
console.log(_.minBy([], "n"));   // undefined
console.log(_.minBy(null, "n")); // undefined
Try It Yourself

How It Works

  1. Empty. No elements to rank → undefined.
  2. null. Treated as falsey input → undefined.
  3. Default. Use ?? fallback when you need a stand-in.
  4. Not Infinity. Lodash does not invent a numeric sentinel here.

Example 5 — _.min vs _.minBy

Flat numbers use min; object fields use minBy.

Lodash
var nums = [4, 2, 8, 6];
var objects = [{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }];

console.log(_.min(nums));          // 2
console.log(_.minBy(objects, "n")); // { n: 2 }
Try It Yourself

How It Works

  1. Flat. _.min returns the smallest number.
  2. Objects. _.minBy returns the object that owns the smallest n.
  3. Same idea. Both find a minimum — different return shapes.
  4. Rule. Numbers → min; properties → minBy.

Browser & Runtime Support

_.minBy is a Lodash Math helper (available since 4.0.0, stable in 4.x). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native alternatives map then reduce; Lodash adds iteratee shorthands.

✓ Stable · Lodash 4.0.0+

_.minBy()

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

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import minBy from "lodash/minBy" for smaller builds. Use property shorthand for simple fields; use a function for computed ranks.

Frequently Asked Questions

_.minBy(array, iteratee) is like _.min, but ranks each element by an iteratee first. It returns the original element with the lowest score — official docs: { n: 1 } from [{ n: 1 }, { n: 2 }].
_.min compares array values directly. _.minBy maps each element through an iteratee (function or property path), compares those scores, then returns the original winning element. Use _.minBy for object arrays.
Yes. _.minBy(arr, 'n') is the _.property shorthand for reading o.n. Nested paths like 'price.base' work too.
Like _.min, empty or falsey arrays return undefined — no throw, no Infinity.
The first element that reaches the minimum score wins. Later equals do not replace it.
Use import minBy from "lodash/minBy" or require("lodash/minBy") so bundlers can tree-shake. Full build: import _ from "lodash" then _.minBy.

Next: _.multiply()

Multiply two numbers with Lodash.

_.multiply() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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