Lodash _.omitBy() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Build a new object by dropping properties where a predicate returns truthy. Part of Lodash Object (stable — not deprecated). The predicate is invoked as (value, key). Opposite of _.pickBy.

Pass the object and path or keys shown below. Check whether the helper mutates or returns a new object.

Syntax

Call _.omitBy. Start with this line.

Lodash
_.omitBy(object, [predicate=_.identity])
CallWhat it does
_.omitBy(object, [predicate=_.identity])Primary signature.
_.omitBy(object)Work with an object’s keys, values, or paths.

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

Library declarations
Lodash
_.omitBy(object, [predicate=_.identity])

Parameters

ParameterDescription
objectRequired. Source object to filter
predicateOptional. Invoked as (value, key); default _.identity

Return Value

Return ValueDescription
*New object without matching properties

Lodash Examples

Example 1 — Official: Omit Numbers

Drop every property whose value is a number.

Lodash
var object = { a: 1, b: "2", c: 3 };

_.omitBy(object, _.isNumber);
// → { b: "2" }
Try It Yourself

How It Works

  1. Predicate. _.isNumber checks each value.
  2. Omit. 1 and 3 are numbers → dropped.
  3. Keep. "2" is a string → kept.
  4. Docs. Matches the official Lodash example.

Example 2 — Omit null / undefined

Keep 0 and false; drop only nil values.

Lodash
var data = {
  name: "Ada",
  score: 0,
  active: false,
  note: null,
  meta: undefined
};

_.omitBy(data, _.isNil);
// → { name: "Ada", score: 0, active: false }
Try It Yourself

How It Works

  1. isNil. True only for null and undefined.
  2. Keep. 0 and false stay — they are not nil.
  3. Contrast. Default identity would also drop 0 / false.
  4. Use. Common sanitize step before APIs or forms.

Example 3 — Omit by Key Name

Use the second predicate argument to filter keys.

Lodash
var user = {
  id: 1,
  name: "Sam",
  _token: "secret",
  _cache: true
};

_.omitBy(user, function (value, key) {
  return key.charAt(0) === "_";
});
// → { id: 1, name: "Sam" }
Try It Yourself

How It Works

  1. Key. Predicate receives key as the second arg.
  2. Rule. Keys starting with _ return truthy → omitted.
  3. Public. id and name remain.
  4. Tip. For a fixed list of names, _.omit is simpler.

Example 4 — omitBy vs pickBy

Same predicate, opposite results.

Lodash
var object = { a: 1, b: "2", c: 3 };

console.log(_.omitBy(object, _.isNumber));
// → { b: "2" }

console.log(_.pickBy(object, _.isNumber));
// → { a: 1, c: 3 }
Try It Yourself

How It Works

  1. omitBy. Truthy predicate → drop.
  2. pickBy. Truthy predicate → keep.
  3. Same test. _.isNumber on the same object.
  4. Pick. Choose the helper that matches “drop” vs “keep” intent.

Example 5 — omitBy vs omit

Predicate rules vs a fixed key list.

Lodash
var user = { id: 1, name: "Sam", password: "x" };

_.omit(user, "password");
// → { id: 1, name: "Sam" }

_.omitBy(user, function (value, key) {
  return key === "password";
});
// → { id: 1, name: "Sam" }
Try It Yourself

How It Works

  1. omit. Best when keys are known literals.
  2. omitBy. Best when the rule depends on value or a pattern.
  3. Same result. Both drop password here.
  4. Choose. Prefer the shorter, clearer API for the job.

Browser & Runtime Support

_.omitBy is a Lodash Object helper available in 4.x. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native equivalents loop Object.keys and copy keys the predicate rejects.

✓ Stable · Lodash 4.x

_.omitBy()

Available in [email protected] full builds and the lodash/omitBy 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
_.omitBy Lodash 4.x

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import omitBy from "lodash/omitBy" for smaller builds. Use omit for fixed key lists; pickBy when you want to keep matches.

Frequently Asked Questions

_.omitBy(object, [predicate]) builds a new object from own enumerable string keys, dropping any property where the predicate returns a truthy value. Official example: _.omitBy({ a: 1, b: '2', c: 3 }, _.isNumber) → { b: '2' }.
The predicate is invoked as predicate(value, key). Check the value for content rules, or the key for name-based rules.
No. It returns a new object and leaves the source unchanged.
_.omit() takes a fixed list of paths/keys. _.omitBy() decides per property with a runtime predicate.
They are opposites. _.omitBy() drops where the predicate is truthy; _.pickBy() keeps where the predicate is truthy.
The default is _.identity, so truthy values are omitted and only falsy values remain. Prefer an explicit predicate like _.isNil when you only want to drop null/undefined.

Next: _.pick()

Keep a fixed list of object paths or keys.

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