Lodash _.pick() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Build a new object with only the property paths you name — an allow-list. Part of Lodash Object (stable — not deprecated). Opposite of _.omit for fixed key lists.

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

Syntax

Call _.pick. Start with this line.

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

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

Library declarations
Lodash
_.pick(object, [paths])

Parameters

ParameterDescription
objectRequired. Source object
pathsRequired. Property paths to keep (array or rest args)

Return Value

Return ValueDescription
*New object with only those paths

Lodash Examples

Example 1 — Official: Pick with an Array

Keep only the listed top-level keys.

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

_.pick(object, ["a", "c"]);
// → { a: 1, c: 3 }
Try It Yourself

How It Works

  1. Allow-list. Only a and c are requested.
  2. Copy. Values 1 and 3 are copied into a new object.
  3. Skip. b is not listed, so it is left out.
  4. Docs. Matches the official Lodash example.

Example 2 — Rest Arguments

Same result without wrapping paths in an array.

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

_.pick(object, "a", "c");
// → { a: 1, c: 3 }
Try It Yourself

How It Works

  1. Rest. Extra args after the object are treated as paths.
  2. Same. Equivalent to ['a', 'c'].
  3. Style. Use arrays when paths come from a variable.
  4. Style. Use rest args for short literal lists.

Example 3 — Nested Path

Dotted paths pick into nested objects.

Lodash
var user = {
  id: 1,
  profile: { name: "Ada", city: "London" },
  role: "admin"
};

_.pick(user, ["id", "profile.name"]);
// → { id: 1, profile: { name: "Ada" } }
Try It Yourself

How It Works

  1. Top. id is copied as usual.
  2. Nested. profile.name rebuilds a partial profile object.
  3. Drop. city and role are not requested.
  4. Note. Nested picks are shallow structures built for those paths.

Example 4 — Missing Keys Are Skipped

Unknown paths do not throw.

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

_.pick(object, ["a", "z"]);
// → { a: 1 }
Try It Yourself

How It Works

  1. Found. a exists → copied.
  2. Missing. z is absent → ignored.
  3. No error. Safe for optional allow-lists.
  4. Tip. Check keys first if absence must be an error.

Example 5 — pick vs omit

Allow-list vs deny-list on the same object.

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

console.log(_.pick(user, ["id", "name"]));
// → { id: 1, name: "Sam" }

console.log(_.omit(user, ["password"]));
// → { id: 1, name: "Sam" }
Try It Yourself

How It Works

  1. pick. Names what to keep — safer for API allow-lists.
  2. omit. Names what to drop — fine when secrets are few and known.
  3. Same result. Both remove password here.
  4. Prefer pick when new fields might appear and must stay private by default.

Browser & Runtime Support

_.pick 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 alternatives include object rest/destructuring for top-level keys, or a small loop over paths.

✓ Stable · Lodash 4.x

_.pick()

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

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import pick from "lodash/pick" for smaller builds. Use pickBy for predicates; omit for deny-lists.

Frequently Asked Questions

_.pick(object, [paths]) creates a new object with only the listed property paths. Official example: _.pick({ a: 1, b: '2', c: 3 }, ['a', 'c']) → { a: 1, c: 3 }.
Pass an array (_.pick(obj, ['a', 'c'])) or rest arguments (_.pick(obj, 'a', 'c')). Both forms are equivalent.
No. It returns a new object and leaves the source unchanged (shallow copy of picked values).
Lodash skips it quietly. The result simply omits that key — no error is thrown.
_.pick() is an allow-list (name what to keep). _.omit() is a deny-list (name what to remove).
Use _.pickBy() when selection depends on a runtime condition. Use _.pick() when you already know the exact paths to keep.

Next: _.pickBy()

Keep object properties with a predicate instead of fixed paths.

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