Ramda.js R.evolve() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Ramda’s R.evolve() answers a field-update question: give me a copy of this object with these named functions applied. You pass a transformations object, then the record. You get a new object. Keys without a matching function are copied. Nested transformation objects recurse. A function for a missing key is never called.

The official Tomato sample is the whole idea. Trim a padded name, add one to nested elapsed, subtract one from remaining, leave id alone, and skip lastName because it is not there. Native JavaScript would spread, then rewrite each field. That is data-first and painful to reuse. evolve is data-last, so R.evolve({ lives: R.dec }) is already a function of one object — ready for R.map or R.pipe. Need to set a key to a known value? That is R.assoc. Need one function on every value? That is R.map. Lodash has no direct _.evolve; you would nest _.update calls.

Syntax

Call R.evolve. Start with this line.

Ramda
R.evolve(transformations, object)
CallWhat it does
R.evolve(transformations, object)Primary signature.
R.evolve(...)Call the object helper.

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

Library declarations
Ramda
R.evolve(transformations, object)

Parameters

ParameterDescription
transformationsRequired. Object. A recipe. Functions update matching keys. Nested objects recurse. Keys that are not on object are ignored.
objectRequired. Object or Array. The source. It is never mutated. If the value is not an object or array, it is returned as-is.

Return Value

Return ValueDescription
Object or ArrayA new object or array with matching keys transformed. Other keys are copied. Nested values without a transform are copied by reference. Primitives and null are returned unchanged.

Ramda Examples

📚 Getting Started

The official Ramda sample, then the same helper with one field so you can see what stays shared.

Example 1 — Official Tomato

Trim a padded name, update nested counters, skip a missing lastName, copy id.

Ramda
const tomato = {
  firstName: '  Tomato ',
  data: { elapsed: 100, remaining: 1400 },
  id: 123
};
const transformations = {
  firstName: R.trim,
  lastName: R.trim, // Will not get invoked.
  data: { elapsed: R.add(1), remaining: R.add(-1) }
};

R.evolve(transformations, tomato);
//=> { firstName: 'Tomato', data: { elapsed: 101, remaining: 1399 }, id: 123 }
Try It Yourself

How It Works

firstName is a function, so Ramda calls R.trim. data is a nested object, so evolve recurses. id has no recipe, so it is copied. lastName is not on the Tomato, so R.trim never runs. That is the docs sample from ramdajs.com.

Example 2 — No Mutation, Shared Nested Refs

The original name stays padded. Nested data is copied by reference because it has no transform.

Ramda
const orig = { firstName: '  Ada ', data: { elapsed: 100 } };
const copy = R.evolve({ firstName: R.trim }, orig);

copy;
//=> { firstName: 'Ada', data: { elapsed: 100 } }

orig;
//=> { firstName: '  Ada ', data: { elapsed: 100 } }

copy.data === orig.data;
//=> true
Try It Yourself

How It Works

The docs say non-primitive properties are copied by reference. Only keys you transform (or recurse into) get new nested objects. Mutating copy.data.elapsed would also change orig.data. Recurse with { data: { elapsed: R.inc } } when you need a new nested object.

📈 Practical Patterns

A nested lives tick versus assoc, then arrays and primitives, then a curried helper mapped over rows.

Example 3 — Nested Recipe vs assoc

A nested transform decrements stats.lives and keeps score. assoc replaces a whole top-level key instead.

Ramda
const player = { name: 'Ada', stats: { lives: 3, score: 10 } };

R.evolve({ stats: { lives: R.dec } }, player);
//=> { name: 'Ada', stats: { lives: 2, score: 10 } }

R.assoc('name', 'Bo', player);
//=> { name: 'Bo', stats: { lives: 3, score: 10 } }

player;
//=> { name: 'Ada', stats: { lives: 3, score: 10 } }
Try It Yourself

How It Works

Nested { lives: R.dec } is an object, so evolve recurses into stats and builds a new nested object. R.assoc does not read the previous value; it writes the one you pass. Both leave the original player intact. Pair evolve with R.dec when the next value depends on the current one.

Example 4 — Arrays and Primitives

Integer keys transform array items. A number or null is not an object or array, so it is returned unchanged.

Ramda
R.evolve({ 0: R.toUpper }, ['ada', 'bo']);
//=> ['ADA', 'bo']

R.evolve({ n: R.inc }, 5);
//=> 5

R.evolve({ n: R.inc }, null);
//=> null
Try It Yourself

How It Works

Arrays allocate [] and walk indexes. { 0: R.toUpper } is the same key as '0'. Values that fail the object/array check return immediately, so evolve is safe to drop into a pipe that sometimes sees null.

Example 5 — Curry and Map

Fill the recipe to get a function of one object. Map it over rows with R.map.

Ramda
const tick = R.evolve({ lives: R.dec, label: R.trim });

tick({ lives: 3, label: '  Ada ' });
//=> { lives: 2, label: 'Ada' }

R.map(tick, [{ lives: 3, label: '  a ' }, { lives: 1, label: '  b ' }]);
//=> [{ lives: 2, label: 'a' }, { lives: 0, label: 'b' }]
Try It Yourself

How It Works

Because evolve is arity 2, filling transformations leaves a function of one object, ready for R.map and R.pipe. That is the same pattern used with R.dec in the Math tutorials.

Browser Support

R.evolve() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.

✓ Ramda 0.9.0+ · Any JS runtime

Ramda.js R.evolve()

Load Ramda 0.9.0 or later via CDN or npm, then call R.evolve with a transformations object and a record. No extra browser API is required.

100% With Ramda 0.9.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.evolve() Universal

Bottom line: Safe in any project that includes Ramda 0.9.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.evolve(transformations, object) returns a new object (or array) by running a function for each matching key. Nested transformation objects recurse. Added in v0.9.0. The original value is not mutated.
A tomato record with firstName: ' Tomato ' and nested data.elapsed / remaining. After evolve, firstName is 'Tomato', elapsed is 101, remaining is 1399, and id stays 123. lastName is never called because it is missing.
No. It builds a new object or array. Keys without a transform are copied as-is. Nested objects that are not transformed are copied by reference, so they are still shared with the original.
That function is not invoked. evolve only walks keys that exist on the object. Extra keys on the transformations object are ignored.
assoc sets one key to a new value. evolve runs a function on the current value of each named key. map walks a list (or the values of an object) with one function, not a per-key recipe.
No. R.evolve is a stable Ramda object helper from v0.9.0. It is not deprecated, experimental, or non-standard.

Continue to R.forEachObjIndexed()

Learn how to walk an object’s keys and values for side effects using Ramda R.forEachObjIndexed().

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