Ramda.js R.mergeDeepLeft() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Ramda’s R.mergeDeepLeft() answers a nested-merge question: how do I combine two records so inner objects mix, while the first record still wins when a field is not two objects? You pass the left object, then the right object. You get a new object. Neither source is mutated.

The official sample is the whole idea. Left has name, age: 10, and contact.email of [email protected]. Right has age: 40 and a different nested email. The result keeps fred, age 10, and the moo address. Need the second record to win instead? That is R.mergeDeepRight. Need a shallow overlay? That is R.mergeLeft. Need a custom clash rule? That is R.mergeDeepWith or R.mergeDeepWithKey.

Syntax

Call R.mergeDeepLeft. Start with this line.

Ramda
R.mergeDeepLeft(lObj, rObj)
CallWhat it does
R.mergeDeepLeft(lObj, rObj)Primary signature.
R.mergeDeepLeft(...)Call the object helper.

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

Library declarations
Ramda
R.mergeDeepLeft(lObj, rObj)

Parameters

ParameterDescription
lObjRequired. Object. The first record. On a clash that is not two nested objects, this value is kept.
rObjRequired. Object. The second record. Own keys that do not exist on the left are copied. Nested objects still merge.

Return Value

Return ValueDescription
ObjectA new object with own properties from both sides. Nested plain objects are merged recursively. The source objects are not mutated.

Ramda Examples

📚 Getting Started

The official nested merge, then the same inputs with mergeDeepRight so the second record wins.

Example 1 — Official fred

Left age and nested email win. name exists only on the left and is kept.

Ramda
R.mergeDeepLeft(
  { name: 'fred', age: 10, contact: { email: '[email protected]' } },
  { age: 40, contact: { email: '[email protected]' } }
);
//=> { name: 'fred', age: 10, contact: { email: '[email protected]' } }
Try It Yourself

How It Works

age is two numbers, so left 10 is kept. contact is two objects, so it recurses, then left email is kept. That is the docs example from ramdajs.com.

Example 2 — vs R.mergeDeepRight

Same two records. Flip which side wins on a clash.

Ramda
const left = { name: 'fred', age: 10, contact: { email: '[email protected]' } };
const right = { age: 40, contact: { email: '[email protected]' } };

R.mergeDeepLeft(left, right);
//=> { name: 'fred', age: 10, contact: { email: '[email protected]' } }
R.mergeDeepRight(left, right);
//=> { name: 'fred', age: 40, contact: { email: '[email protected]' } }
Try It Yourself

How It Works

name is only on the left, so both helpers keep fred. Only the clash fields change: age and nested email.

📈 Practical Patterns

Shallow vs deep, extra nested keys from both sides, then a curried overlay in a pipe.

Example 3 — vs R.mergeLeft

Shallow merge replaces the whole contact. Deep merge keeps left email and still copies right-only phone.

Ramda
const left = { name: 'fred', contact: { email: '[email protected]' } };
const right = { age: 40, contact: { email: '[email protected]', phone: '555' } };

R.mergeLeft(left, right);
//=> { age: 40, contact: { email: '[email protected]' }, name: 'fred' }
R.mergeDeepLeft(left, right);
//=> { name: 'fred', age: 40, contact: { email: '[email protected]', phone: '555' } }
Try It Yourself

How It Works

R.mergeLeft is Object.assign({}, right, left) in spirit: one level only. Deep merge is the helper to pick when nested extras on the right still matter.

Example 4 — Nested Keys from Both Sides

Left name and city win. Right-only twitter and active are still kept. Sources stay unchanged.

Ramda
const left = { user: { name: 'Ada', city: 'London' }, role: 'lead' };
const right = { user: { name: 'Grace', twitter: '@grace' }, active: true };
const merged = R.mergeDeepLeft(left, right);

merged;
//=> { user: { name: 'Ada', city: 'London', twitter: '@grace' }, role: 'lead', active: true }
left;
//=> { user: { name: 'Ada', city: 'London' }, role: 'lead' }
right;
//=> { user: { name: 'Grace', twitter: '@grace' }, active: true }
Try It Yourself

How It Works

Recursion only copies nested objects into a new object. The original left.user and right.user objects are not assigned to.

Example 5 — Curry with pipe

Fix nested overrides first, then read a nested flag. Both helpers are data-last.

Ramda
const applyOverrides = R.mergeDeepLeft({ theme: { dark: true } });
const darkFlag = R.pipe(
  R.mergeDeepLeft({ theme: { dark: true } }),
  R.path(['theme', 'dark'])
);
const base = { theme: { dark: false, font: 'sans' }, lang: 'en' };

applyOverrides(base);
//=> { theme: { dark: true, font: 'sans' }, lang: 'en' }
darkFlag(base);
//=> true
Try It Yourself

How It Works

R.mergeDeepLeft(overrides) waits for the base object. Nested font from the base survives because it exists only on the right.

Browser Support

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

✓ Ramda 0.24.0+ · Any JS runtime

Ramda.js R.mergeDeepLeft()

Load Ramda 0.24.0 or later via CDN or npm, then call R.mergeDeepLeft with two objects. No extra browser API is required.

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

Bottom line: Safe in any project that includes Ramda 0.24.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.mergeDeepLeft(lObj, rObj) returns a new object with own properties from both records. Nested plain objects are merged recursively. On a clash that is not two objects, the left value is kept. Added in v0.24.0. Neither source object is mutated.
R.mergeDeepLeft({ name: 'fred', age: 10, contact: { email: '[email protected]' } }, { age: 40, contact: { email: '[email protected]' } }) is { name: 'fred', age: 10, contact: { email: '[email protected]' } }. Left age and nested email win. name exists only on the left and is kept.
Both deep-merge nested objects. mergeDeepLeft keeps the first object's value on a clash. mergeDeepRight keeps the second object's value. Keys that exist on only one side are always kept.
mergeLeft is shallow: a nested contact object from the left replaces the whole right contact. mergeDeepLeft walks into both contact objects, so left email can win while a right-only phone is still copied.
No. Ramda treats a value as nested only when both sides are plain objects ([object Object]). Arrays, dates, and other types are a clash, so the left array replaces the right array.
No. R.mergeDeepLeft is a stable Ramda object helper from v0.24.0. It is not deprecated, experimental, or non-standard.

Continue to R.mergeDeepRight()

Learn how to deep-merge two objects so nested right values win using Ramda R.mergeDeepRight().

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