Underscore.js _.omit() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Return a copy of the object, filtered to omit the blacklisted keys (or an array of keys). Alternatively accepts a predicate indicating which keys to omit (official Underscore docs). Stable helper — not deprecated. Does not mutate the source.

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

Syntax

Call _.omit. Start with this line.

Underscore
_.omit(object, *keys) or predicate Returns New object without blacklisted keys Official example _.omit({name, age, userid}, "userid")
CallWhat it does
_.omit(object, *keys) or predicate Returns New object without blacklisted keys Official example _.omit({name, age, userid}, "userid")Primary signature.
_.omit(...)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
_.omit(object, *keys) or predicate Returns New object without blacklisted keys Official example _.omit({name, age, userid}, "userid")

Parameters

ParameterDescription
objectRequired. Source to copy from
*keys / arrayOptional. Property names to blacklist
predicateOptional. (value, key, object) → true means drop

Return Value

Return ValueDescription
*New object without omitted keys

Underscore.js Examples

Example 1 — Official: Drop userid

The docs remove one blacklisted key and keep everything else.

Underscore
_.omit({name: "moe", age: 50, userid: "moe1"}, "userid");
// → {name: "moe", age: 50}
Try It Yourself

How It Works

  1. Source. Three own properties: name, age, userid.
  2. Blacklist. Only "userid" is listed to omit.
  3. Copy. Underscore builds a new object with the other keys.
  4. Official result. {name: "moe", age: 50}.

Example 2 — Omit Several Keys

Pass multiple names, or one array of names.

Underscore
var moe = {name: "moe", age: 50, userid: "moe1"};

_.omit(moe, "age", "userid");
// → {name: "moe"}

_.omit(moe, ["age", "userid"]);
// → {name: "moe"}   // same idea
Try It Yourself

How It Works

  1. Varargs. List keys as separate string arguments.
  2. Array form. Or pass one array of key names.
  3. Same result. Both drop age and userid.
  4. Safe. moe itself is not modified.

Example 3 — Predicate: Drop Numbers

Official style: omit properties where the value is a number.

Underscore
_.omit({name: "moe", age: 50, userid: "moe1"}, function (value, key, object) {
  return _.isNumber(value);
});
// → {name: "moe", userid: "moe1"}
Try It Yourself

How It Works

  1. Predicate. Called as (value, key, object) for each own key.
  2. True means drop. age: 50 is a number → omitted.
  3. Keep strings. name and userid stay.
  4. Official pattern. Same idea as the docs predicate example.

Example 4 — _.omit vs _.pick

Blacklist versus whitelist on the same object.

Underscore
var moe = {name: "moe", age: 50, userid: "moe1"};

_.omit(moe, "userid");
// → {name: "moe", age: 50}

_.pick(moe, "name", "age");
// → {name: "moe", age: 50}   // same result, opposite approach
Try It Yourself

How It Works

  1. omit. Name what to remove — see this page.
  2. pick. Name what to keep — see _.pick.
  3. Same outcome. Here both leave name and age.
  4. Choose. Prefer omit when the drop list is shorter; pick when the keep list is shorter.

Browser & Runtime Support

_.omit 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. On modern engines you can approximate key lists with object rest, but Underscore remains handy for arrays of keys and predicates.

✓ Stable · Underscore 1.x

_.omit()

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
_.omit Underscore 1.x+

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

Frequently Asked Questions

_.omit(object, *keys) returns a copy of the object with the blacklisted keys removed. Official example: _.omit({name: 'moe', age: 50, userid: 'moe1'}, 'userid') returns {name: 'moe', age: 50}.
No. It returns a new object. The source is left untouched.
They are opposites. _.omit removes the keys you name (blacklist). _.pick keeps only the keys you name (whitelist).
Yes. A predicate (value, key, object) drops every property for which it returns true — useful to omit by type or pattern.
Missing keys are ignored. No error is thrown.
No. It is a stable Underscore object helper. Load Underscore 1.x and call _.omit(object, *keys).

Next: _.defaults()

Fill missing properties from one or more default objects.

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