Ramda.js R.map() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

R.map(fn, list) calls fn on every item and returns a new list of the results, in the same order (official Ramda docs). It works like native Array.prototype.map, but takes the function first, is curried, and also maps the values of plain objects.

Stable since v0.1.0: R.map is one of Ramda’s original functions. It is not deprecated, experimental, or non-standard.

Syntax

Call R.map. Start with this line.

Ramda
R.map(fn, list) or R.map(fn)(list)
CallWhat it does
R.map(fn, list) or R.map(fn)(list)Primary signature.
R.map(...)Call the list helper.

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

Library declarations
Ramda
R.map(fn, list) or R.map(fn)(list)

Parameters

ParameterDescription
fnRequired. Called with one argument: the item (or object value)
listRequired. Array, plain object, function, or any value with a map method — never changed

Return Value

Return ValueDescription
*A new value of the same shape (array → array, object → object)

Ramda Examples

Example 1 — Official Samples: Array and Object

Double every number in an array, then every value in an object.

Ramda
const double = x => x * 2;

console.log(R.map(double, [1, 2, 3]));          // [2, 4, 6]
console.log(R.map(double, { x: 1, y: 2, z: 3 })); // { x: 2, y: 4, z: 6 }
Try It Yourself

How It Works

  1. One-item function. double only knows how to change a single number.
  2. Array. R.map calls double on 1, 2, 3 and collects [2, 4, 6] in a new array.
  3. Object. For a plain object, it keeps the keys x, y, z and transforms each value.
  4. Same shape. An array gives back an array; an object gives back an object.

Example 2 — Pick a Field from Each Object

Turn a list of users into a list of names.

Ramda
const users = [
  { name: 'Ann', age: 31 },
  { name: 'Bob', age: 25 }
];

console.log(R.map(R.prop('name'), users)); // ['Ann', 'Bob']
console.log(R.pluck('name', users));       // ['Ann', 'Bob']
console.log(users[0]);                     // { name: 'Ann', age: 31 }
Try It Yourself

How It Works

  1. Field reader. R.prop('name') is a function that reads name from one object.
  2. Map it. R.map runs that reader on each user and collects the names.
  3. Shortcut. R.pluck('name', users) is exactly R.map(R.prop('name'), users).
  4. Nothing changed. The user objects are untouched — only a new array of names is created.

Example 3 — Reuse a Mapper in a Pipe

Leave out the data to get a reusable step, then combine it with other steps.

Ramda
const shout = R.pipe(
  R.map(R.toUpper),
  R.join(' ')
);

console.log(shout(['hi', 'there'])); // 'HI THERE'
console.log(shout([]));              // ''
Try It Yourself

How It Works

  1. Curried mapper. R.map(R.toUpper) has no data yet, so it returns a function waiting for a list.
  2. Step 1. R.pipe sends ['hi', 'there'] through the mapper: ['HI', 'THERE'].
  3. Step 2. R.join(' ') glues the words into 'HI THERE'.
  4. Empty is safe. Mapping [] gives [], and joining that gives an empty string (a blank output line).

Example 4 — Only the Value Is Passed (parseInt and addIndex)

Native map passes the index too, which breaks parseInt. Ramda does not — and R.addIndex adds it back when you want it.

Ramda
console.log(['1', '2', '3'].map(parseInt));  // [1, NaN, NaN]
console.log(R.map(parseInt, ['1', '2', '3'])); // [1, 2, 3]

const mapIndexed = R.addIndex(R.map);
console.log(mapIndexed((item, i) => (i + 1) + '. ' + item, ['tea', 'milk']));
// ['1. tea', '2. milk']
Try It Yourself

How It Works

  1. Native trap. Native map calls parseInt('2', 1) — the index becomes the radix, so the result is NaN. (JSON.stringify prints NaN as null.)
  2. Ramda is safe. R.map calls parseInt with only the string, so every value parses.
  3. Want the index? R.addIndex(R.map) makes a new map that also passes the index as the second argument.
  4. Numbering. Index 0 becomes '1. tea', index 1 becomes '2. milk'.

Example 5 — Mapping Over a Function

Give R.map a function instead of a list, and it builds a new function that runs both in order.

Ramda
const doubleThenInc = R.map(R.inc, R.multiply(2));

console.log(typeof doubleThenInc); // 'function'
console.log(doubleThenInc(5));     // 11
Try It Yourself

How It Works

  1. Function as data. R.multiply(2) is a function, so R.map composes instead of looping.
  2. Run the inner one first. doubleThenInc(5) calls R.multiply(2)(5) = 10.
  3. Then map over the result. R.inc(10) = 11.
  4. Same as compose. It equals R.compose(R.inc, R.multiply(2)) — a handy idea, but prefer compose or pipe for readability.

Browser & Runtime Support

R.map() is plain JavaScript inside Ramda (available since v0.1.0). It uses no browser API, so support depends only on loading Ramda.

✓ Ramda 0.1.0+ · Any JS runtime

Ramda.js R.map()

The UMD build (ramda.min.js) is compiled to ES5 syntax, so it runs in Chrome, Firefox, Safari, and Edge. Via npm it works in Node.js, Deno, and Bun with require or import. The arrow functions in some examples need an ES2015+ engine, which every modern browser has.

100% With Ramda loaded
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
R.map() Universal

Bottom line: Safe in any project that includes Ramda. Load ramda.min.js from a CDN in the browser, or npm install ramda for Node, Deno, and Bun. These labs load [email protected] from jsDelivr.

Frequently Asked Questions

R.map(fn, list) calls fn on every item and returns a new list of the results, in the same order. The original list is not changed. Official sample: R.map(x => x * 2, [1, 2, 3]) returns [2, 4, 6].
R.map takes the function first and the data last, and it is curried, so R.map(double) is a reusable function for R.pipe. It also maps plain objects and functions, passes only the value to your callback (no index or array), and visits holes in sparse arrays.
Yes. R.map(fn, { x: 1, y: 2 }) returns a new object with the same keys and transformed values: { x: fn(1), y: fn(2) }. Only own enumerable keys are used. If you also need the key, use R.mapObjIndexed.
R.map passes only the item. Wrap it with R.addIndex: R.addIndex(R.map)((item, i) => i + ': ' + item, list). The index is passed as the second argument.
Native map passes (item, index, array), so parseInt receives the index as its radix and returns NaN for '2' and '3'. R.map passes only the item, so R.map(parseInt, ['1', '2', '3']) returns [1, 2, 3].
No. R.map has been a stable Ramda function since v0.1.0. It is not deprecated, experimental, or non-standard.

Next: R.mapAccum()

Map a list while carrying a running value from item to item.

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