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)
Call
What 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
Parameter
Description
names
Required. Array. String property names to copy onto the new object. Duplicates copy once. An empty list yields {}.
obj
Required. Object. The source. The source is never mutated. Nested values stay shared by reference.
Return Value
Return Value
Description
Object
A 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.
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.
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.
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.
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.
Compatibility
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 ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll 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.