Ramda.js R.prop() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Ramda’s R.prop() answers a one-field question: what is the value at this name? You pass a key (or an integer index), then an object. You get that value, or undefined if it is missing. Native JavaScript is obj[p], but that throws on null and is awkward to drop into map. prop is data-last, so R.prop('name') is already a function of one object — ready for R.map, R.pipe, or R.compose.

The official sample is the whole idea. R.prop('x', {x: 100}) is 100. R.prop('x', {}) is undefined. R.prop(0, [100]) is 100. Then the curry payoff: R.compose(R.inc, R.prop('x'))({ x: 3 }) is 4. Need a nested walk? That is R.path. Need one column from many rows? That is R.pluck (map of prop). Need several keys from one object as an array? That is R.props. Need a default when the value is undefined? Next Object helper is R.propOr.

Syntax

Call R.prop. Start with this line.

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

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

Library declarations
Ramda
R.prop(p, obj)

Parameters

ParameterDescription
pRequired. String, Int, or Symbol. The property name or array index. An integer uses nth (negative indexes count from the end). Other values use obj[p].
objRequired. Object or Array. The value to query. null and undefined return undefined instead of throwing. The source is never mutated.

Return Value

Return ValueDescription
Any or undefinedThe value at that key or index. A missing name is undefined. Falsy stored values such as 0 and false are returned as-is — they are not treated as missing.

Ramda Examples

📚 Getting Started

The official getter, then integer indexes on arrays.

Example 1 — Official x Getter

Read x when it exists. A missing name is undefined, not a throw.

Ramda
R.prop('x', {x: 100});
//=> 100

R.prop('x', {});
//=> undefined
Try It Yourself

How It Works

That is the docs sample from ramdajs.com. Labs print missing values with String() because JSON.stringify(undefined) is blank.

Example 2 — Array Indexes

An integer p uses nth, so negatives count from the end. A string key still uses obj[p].

Ramda
R.prop(0, [100]);
//=> 100

R.prop(-1, [10, 20, 30]);
//=> 30

R.prop('1', [10, 20, 30]);
//=> 20
Try It Yourself

How It Works

0 is an integer, so Ramda calls nth. '1' is a string, so it is a property name. On arrays those coincide for non-negative positions.

📈 Practical Patterns

Compare path, pluck, and nth, then compose and map, then null-safe reads and falsy values.

Example 3 — vs path, pluck, and nth

prop stops at one key. path walks nested names. pluck maps prop. nth matches integer prop.

Ramda
const nested = {a: {b: 1}};

R.prop('a', nested);
//=> {b: 1}

R.path(['a', 'b'], nested);
//=> 1

R.pluck('x', [{x: 1}, {x: 2}]);
//=> [1, 2]

R.nth(0, [100]);
//=> 100
Try It Yourself

How It Works

R.prop('a.b', nested) would look for a key literally named a.b. Nested walks belong to path.

Example 4 — Compose and Map

Fill the key to get a function of one object. The official compose sample increments x. Map the same getter over rows.

Ramda
R.compose(R.inc, R.prop('x'))({ x: 3 });
//=> 4

R.map(R.prop('name'), [
  { name: 'Ada', id: 7 },
  { name: 'Bo', id: 8 }
]);
//=> ['Ada', 'Bo']
Try It Yourself

How It Works

Because prop is arity 2, filling p leaves a function of one object. R.pluck('name', people) is the same map in one helper.

Example 5 — Null Objects and Falsy Values

null and undefined do not throw. Stored 0 and false come back as-is — they are not missing keys.

Ramda
R.prop('x', null);
//=> undefined

R.prop('x', undefined);
//=> undefined

R.prop('n', {n: 0});
//=> 0

R.prop('ok', {ok: false});
//=> false
Try It Yourself

How It Works

Native null.x throws. prop checks obj == null first. Need a fallback for missing keys? That is R.propOr.

Browser Support

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

Load Ramda 0.1.0 or later via CDN or npm, then call R.prop with a key 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.prop() 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.prop(p, obj) returns the value at that property (or array index) if it exists. Missing keys, and null or undefined objects, yield undefined. Added in v0.1.0. The original object is not mutated.
R.prop('x', {x: 100}) is 100. R.prop('x', {}) is undefined. R.prop(0, [100]) is 100. R.compose(R.inc, R.prop('x'))({ x: 3 }) is 4.
prop reads one key on one object (or one index). path walks a nested list of keys. pluck maps prop over a list. When p is an integer, prop delegates to nth, including negative indexes.
A missing name is undefined. R.prop('x', null) and R.prop('x', undefined) also return undefined instead of throwing.
No. It only reads. Nested objects you receive are the same reference as on the source.
No. R.prop is a stable Ramda object helper from v0.1.0. It is not deprecated, experimental, or non-standard.

Continue to R.propOr()

Learn how to read a property with a fallback using Ramda R.propOr().

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