Ramda.js R.pickAll() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Ramda’s R.pickAll() answers a schema question: give me this exact set of keys, and fill blanks with undefined. You pass a list of names, then the object. You get a new object with every listed property. Native JavaScript’s cousin is a destructure: const { a, e, f } = obj then rebuild { a, e, f }. Missing names become undefined there too. pickAll is data-last, so R.pickAll(['id', 'name', 'email']) is already a function of one object — ready for R.map or R.pipe.

The official sample is the whole idea. R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}) is {a: 1, d: 4} — same leftover as R.pick when every name exists. Ask for e and f as well and pickAll keeps them: {a: 1, e: undefined, f: undefined}. pick would have skipped those holes. Need values as an array? That is R.props. Need a predicate? Next is R.pickBy.

Syntax

Call R.pickAll. Start with this line.

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

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

Library declarations
Ramda
R.pickAll(names, obj)

Parameters

ParameterDescription
namesRequired. Array. String property names to copy onto the new object. Every name is assigned, even if missing. An empty list yields {}.
objRequired. Object. The source. The source is never mutated. Nested values stay shared by reference. null or undefined still produce keys whose values are unde...

Return Value

Return ValueDescription
ObjectA new object with a property for every name. Missing names (and stored undefined) are undefined. Key order follows names.

Ramda Examples

📚 Getting Started

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

Example 1 — Official PickAll

When every name exists, the leftover matches pick. When names are missing, pickAll still writes undefined.

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

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

How It Works

Ramda copies a and d when they exist. e and f are not on the source, so their values are undefined, but the keys still exist. That is the docs sample from ramdajs.com.

Example 2 — Schema Fields, Curry

Fill the names list to get a function of one object. Extra secrets stay on the original. A missing email still occupies a key.

Ramda
const orig = { id: 7, name: 'Ada', password: 'secret' };
const row = R.pickAll(['id', 'name', 'email']);

const copy = row(orig);
copy;
//=> {id: 7, name: 'Ada', email: undefined}

'email' in copy;
//=> true

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

How It Works

email is not on orig, but pickAll still writes it. password was never in the schema. Native rest would look the same for the listed keys; pickAll names that schema once for R.map.

📈 Practical Patterns

Compare pick, props, and JSON.stringify, then prove the copy is shallow, then map a schema over many rows.

Example 3 — vs pick, props, and JSON

pick skips the hole. pickAll keeps it. props returns values. JSON.stringify hides undefined keys.

Ramda
const obj = {a: 1, b: 2, c: 3, d: 4};
const all = R.pickAll(['a', 'e'], obj);

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

all;
//=> {a: 1, e: undefined}

R.props(['a', 'e'], obj);
//=> [1, undefined]

JSON.stringify(all);
//=> '{"a":1}'
'e' in all;
//=> true
Try It Yourself

How It Works

That JSON line is the gotcha. The leftover still has e. If you log with JSON.stringify alone, the hole looks gone. Use 'e' in all or print String(all.e) when you need to see it.

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.pickAll(['id', 'profile', 'email'], orig);

copy === orig;
//=> false

copy.profile === orig.profile;
//=> true

'email' in copy;
//=> true
Try It Yourself

How It Works

pickAll 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.pick.

Example 5 — Map, Empty List, Array Indexes

Fill the names and map over rows. An empty names list is {}. Picking array indexes yields a plain object with holes for missing indexes.

Ramda
const row = R.pickAll(['user', 'email']);

R.map(row, [
  { user: 'Ada', email: 'a@x' },
  { user: 'Bo' }
]);
//=> [{user: 'Ada', email: 'a@x'}, {user: 'Bo', email: undefined}]

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

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

How It Works

Because pickAll 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 index '2' is a hole, not a shorter array.

Browser Support

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

Load Ramda 0.1.0 or later via CDN or npm, then call R.pickAll 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.pickAll() 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.pickAll(names, obj) returns a new object with every listed key. If a name is missing, the property is still copied as undefined. Added in v0.1.0. The original object is not mutated.
R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}) is {a: 1, d: 4}. R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}) is {a: 1, e: undefined, f: undefined}.
pick skips missing names. pickAll keeps them as undefined. props returns an array of values (also undefined for misses), not a new object.
JSON has no undefined. JSON.stringify({a: 1, e: undefined}) is {"a":1}. The key is still on the object: 'e' in result is true and result.e is undefined.
No. It always allocates a new object. Nested values are copied by reference, so the copy is shallow.
No. R.pickAll is a stable Ramda object helper from v0.1.0. It is not deprecated, experimental, or non-standard.

Continue to R.pickBy()

Learn how to keep keys by a predicate using Ramda R.pickBy().

R.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.

6 people found this page helpful