Ramda.js R.pick() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Ramda’s R.pick() answers a whitelist question: which keys should the copy keep? You pass a list of names, then the object. You get a new object with only those properties. Native JavaScript’s cousin is a rest destructure you write by hand: const { a, d } = obj; const copy = { a, d }. That is data-first, and missing keys still appear as undefined. pick is data-last, so R.pick(['id', 'name']) is already a function of one object — ready for R.map or R.pipe.

The official sample is the whole idea. R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}) is {a: 1, d: 4}. Ask for e and f as well and they are ignored, leftover {a: 1}. Need the inverse? That is R.omit. Need missing keys to stay as undefined? Next is R.pickAll. Need values as an array? That is R.props.

Syntax

Call R.pick. Start with this line.

Ramda
R.pick(names, obj)
CallWhat it does
R.pick(names, obj)Primary signature.
R.pick(...)Call the object helper.

Prefer import { pick } from "ramda" when you want a named import.

Library declarations
Ramda
R.pick(names, obj)

Parameters

ParameterDescription
namesRequired. Array. String property names to copy onto the new object. Duplicates copy once. An empty list yields {}.
objRequired. Object. The source. The source is never mutated. Nested values stay shared by reference.

Return Value

Return ValueDescription
ObjectA new object with only properties from names that exist on obj. Key order follows names. Missing names are skipped, not set to undefined.

Ramda Examples

📚 Getting Started

The official Ramda sample, then a real whitelist with curry and a name that is not on the object.

Example 1 — Official Pick

Two keys stay. Two keys leave. Missing names are ignored. That is the docs sample from ramdajs.com.

Ramda
R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4});
//=> {a: 1, d: 4}

R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4});
//=> {a: 1}
Try It Yourself

How It Works

Ramda copies a and d onto a new object. e and f are not on the source, so they never appear. That is the docs sample from ramdajs.com.

Example 2 — Public Fields, Curry, Missing Names

Fill the names list to get a function of one object. Extra secrets stay on the original. A name that is not present is ignored.

Ramda
const orig = { id: 7, name: 'Ada', password: 'secret', role: 'admin' };
const publicUser = R.pick(['id', 'name', 'email']);

publicUser(orig);
//=> {id: 7, name: 'Ada'}

orig;
//=> {id: 7, name: 'Ada', password: 'secret', role: 'admin'}
Try It Yourself

How It Works

email is not on orig, so it does not appear. password and role were never in the whitelist. Native rest would still assign email: undefined if you listed it. pick skips the hole.

📈 Practical Patterns

Compare omit, pickAll, and props, then prove the copy is shallow, then map a whitelist over many rows.

Example 3 — vs omit, pickAll, and props

The same source, four leftovers. omit is the inverse. pickAll keeps a missing name as undefined. props returns values.

Ramda
const obj = {a: 1, b: 2, c: 3, d: 4};

R.pick(['a', 'd'], obj);
//=> {a: 1, d: 4}

R.omit(['b', 'c'], obj);
//=> {a: 1, d: 4}

R.pickAll(['a', 'e'], obj);
//=> {a: 1, e: undefined}

R.props(['a', 'd'], obj);
//=> [1, 4]
Try It Yourself

How It Works

omit and pick agree here because the keys you keep are exactly the keys you do not drop. pickAll still writes e, so JSON.stringify drops that hole (JSON has no undefined) but the key exists on the object. props returns an array, not a record.

Example 4 — Shallow Copy, Nested Shared

The outer object is new. Nested objects stay the same reference. Mutating a nested field later still changes the original nested value.

Ramda
const orig = { id: 1, secret: 'x', profile: { city: 'Paris' } };
const copy = R.pick(['id', 'profile'], orig);

copy;
//=> {id: 1, profile: {city: 'Paris'}}

copy === orig;
//=> false

copy.profile === orig.profile;
//=> true
Try It Yourself

How It Works

pick copies property values as-is. profile is still the same object. Clone nested branches yourself (or use R.clone) if later writes must not leak. That is the same shallow rule as R.omit.

Example 5 — Map, Empty List, Array Indexes

Fill the names and map over rows. An empty names list is {}. Picking an array index yields a plain object, not a shorter array.

Ramda
const publicUser = R.pick(['user']);

R.map(publicUser, [
  { user: 'Ada', password: 'a' },
  { user: 'Bo', password: 'b' }
]);
//=> [{user: 'Ada'}, {user: 'Bo'}]

R.pick([], {a: 1, b: 2});
//=> {}

R.pick(['0', '2'], ['a', 'b', 'c']);
//=> {'0': 'a', '2': 'c'}
Try It Yourself

How It Works

Because pick is arity 2, filling names leaves a function of one object, ready for R.map. An empty list copies nothing. The last call walks array indexes as object keys, so you get {'0': 'a', '2': 'c'}, not ['a', 'c']. Need a real array leftover? Use R.props or R.nth.

Browser Support

R.pick() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.

✓ Ramda 0.1.0+ · Any JS runtime

Ramda.js R.pick()

Load Ramda 0.1.0 or later via CDN or npm, then call R.pick with a names array and an object. No extra browser API is required.

100% With Ramda 0.1.0+
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
R.pick() Universal

Bottom line: Safe in any project that includes Ramda 0.1.0 or later. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node. These labs use [email protected].

Frequently Asked Questions

R.pick(names, obj) returns a partial copy of obj containing only the listed keys. If a name is missing, that property is ignored. Added in v0.1.0. The original object is not mutated.
R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}) is {a: 1, d: 4}. R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}) is {a: 1} because e and f are ignored.
No. It always allocates a new object. Nested values are copied by reference, so the copy is shallow.
pick keeps a list of keys. omit drops a list of keys (the inverse). pickAll also keeps missing names as undefined. props returns an array of values, not a new object.
That name is skipped. The leftover object does not get the key. An empty names list yields {}.
No. R.pick is a stable Ramda object helper from v0.1.0. It is not deprecated, experimental, or non-standard.

Continue to R.pickAll()

Learn how to keep listed keys including missing names as undefined using Ramda R.pickAll().

R.pickAll() 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.

6 people found this page helpful