Ramda’s R.props() answers a packing question: give me these keys, as a list of values, in this order. You pass an array of names, then the object. You get an array. The original is never mutated. Native JavaScript’s cousin is [obj.x, obj.y]. That is data-first. props is data-last, so R.props(['first', 'last']) is already a function of one object — ready for R.map, R.pipe, or R.compose.
The official sample is the whole idea. R.props(['x', 'y'], {x: 1, y: 2}) is [1, 2]. A missing name is not skipped: R.props(['c', 'a', 'b'], {b: 2, a: 1}) is [undefined, 1, 2]. Need one key? That is R.prop. Need a new object of those keys? That is R.pick. Need one key off many objects? That is R.pluck. Need nested trails? That is R.paths.
Syntax
Call R.props. Start with this line.
Ramda
R.props(ps, obj)
Call
What it does
R.props(ps, obj)
Primary signature.
R.props(...)
Call the object helper.
Prefer import { props } from "ramda" when you want a named import.
Library declarations
Ramda
R.props(ps, obj)
Parameters
Parameter
Description
ps
Required. Array. Property names to fetch. Order is kept. Integers work as array indexes through R.prop / nth. An empty list returns [].
obj
Required. Object or Array. The source. It is never mutated. null and undefined yield undefined in each slot.
Return Value
Return Value
Description
Array
One leftover per name, in the same order as ps. A missing key is undefined in that slot. Duplicate names duplicate the leftover.
Ramda Examples
📚 Getting Started
The official leftover arrays, then the official compose sample that joins a full name.
Example 1 — Official Ordered Values
Present keys come out in name order. A missing name is a hole, not a skip.
Each name is passed to R.prop. The leftover list follows ['c', 'a', 'b'], not the object’s own key order. c is missing, so slot 0 is undefined. That is the docs sample from ramdajs.com.
Example 2 — Official Full Name with Compose
Fill the names, then join the leftovers. Extra keys such as age are ignored.
compose runs right to left: props packs ['Tony', 'Bullet-Tooth'], then join glues them with a space. The leftover order is the names array, so first comes before last even though the object listed last first. Also from ramdajs.com.
📈 Practical Patterns
Compare cousins, then a curried helper mapped over rows, then holes, indexes, and a null object.
Example 3 — vs prop, pick, and pluck
prop is one leftover. pick is an object. pluck is one key off many objects.
Because props is arity 2, filling the names leaves a function of one object. Extra keys such as extra never appear in the leftover. That list is ready for a table row or a CSV line.
Example 5 — Empty List, Duplicates, Indexes, Null
An empty names list is []. Repeating a name repeats the leftover. Integers index arrays. A null object does not throw.
There is nothing to map when ps is empty. Duplicates are honest: two lookups, two leftovers. Index keys go through nth the same way as R.prop. Native null.name throws; R.prop on null is undefined, so the slot is a hole.
Compatibility
Browser Support
R.props() 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.props()
Load Ramda 0.1.0 or later via CDN or npm, then call R.props 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.props()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.props(ps, obj) reads each listed key with R.prop and returns an array of values in that same order. A missing key is undefined in that slot. Added in v0.1.0. The original object is not mutated.
prop reads one key. pick returns a new object of keys. pluck maps one key over a list of objects. paths walks nested trails. props is several top-level keys on one object, leftover array.
No. That slot is undefined. Native obj.missing is also undefined. A null object yields undefined in each slot instead of throwing.
Yes. The leftover array follows the names array, not the object's own key order.
No. R.props is a stable Ramda object helper from v0.1.0. It is not deprecated, experimental, or non-standard.