Ramda.js R.dissocPath() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Ramda’s R.dissocPath() answers a nested question: give me a copy of this object without the value at this path. You pass an array of keys, then the object. You get a new object. The original is never mutated. Nodes along the path are cloned. Sibling keys stay. A missing path does not throw.

The official sample is the whole idea. R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}) is {a: {b: {}}}. Native JavaScript’s cousin is nested rest: copy a, copy b, omit c. That is data-first and painful to reuse. dissocPath is data-last, so R.dissocPath(['user', 'password']) is already a function of one object — ready for R.map or R.pipe. One top-level key? That is R.dissoc (this helper with a one-item path). Need to put a nested key back? That is R.assocPath. Lodash _.unset writes in place; Ramda clones.

Syntax

Call R.dissocPath. Start with this line.

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

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

Library declarations
Ramda
R.dissocPath(path, obj)

Parameters

ParameterDescription
pathRequired. Array. Keys to walk. Strings (and symbols) are object keys. Integers are array indexes. An empty path returns obj itself.
objRequired. Object or Array. The source. It is never mutated. null and undefined are returned as-is.

Return Value

Return ValueDescription
Object or ArrayA clone equal to the original except the property at the tail of path is omitted. Enumerable prototype properties are flattened onto new objects. Nodes off the path stay shared by reference.

Ramda Examples

📚 Getting Started

The official Ramda sample, then the same path with a sibling key so you can see what stays.

Example 1 — Official Nested Path

The tail of the path is omitted on a clone. An empty inner object remains at b.

Ramda
R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}});
//=> {a: {b: {}}}
Try It Yourself

How It Works

Ramda clones a, then clones b, then skips c. The leftover is an empty b object, not a missing b. That is the docs sample from ramdajs.com.

Example 2 — Siblings Kept

Dropping c leaves d. The original tree still holds c: 42, and the nested b object is a new reference.

Ramda
const orig = {a: {b: {c: 42, d: 1}}};
const copy = R.dissocPath(['a', 'b', 'c'], orig);

copy;
//=> {a: {b: {d: 1}}}

orig;
//=> {a: {b: {c: 42, d: 1}}}

copy.a.b === orig.a.b;
//=> false
Try It Yourself

How It Works

dissocPath cloned b, copied d, and skipped c. orig.a.b.c stays 42. That is why nested deletes belong here, not on R.dissoc of the parent object (which would drop the whole b).

📈 Practical Patterns

A missing path, the one-key cousin dissoc, array indexes, then a curried helper and assocPath as the inverse.

Example 3 — Missing Path vs dissoc

A nested name that is not there still yields a clone. A one-item path matches dissoc.

Ramda
R.dissocPath(['a', 'x', 'y'], {a: {b: 1}});
//=> {a: {b: 1}}

const user = { user: { name: 'Ada' }, role: 'dev' };

R.dissoc('role', user);
//=> { user: { name: 'Ada' } }

R.dissocPath(['role'], user);
//=> { user: { name: 'Ada' } }
Try It Yourself

How It Works

When the next node is missing, Ramda shallow-clones and stops. It does not invent {x: {y: ...}} just to delete it. A one-item path is exactly dissoc: dissoc(prop, obj) is dissocPath([prop], obj).

Example 4 — Array Index in the Path

An integer path segment means “this node is an array.” Index 1 is removed. A string '1' is an object key, not an index.

Ramda
const orig = { items: ['a', 'b', 'c'] };

R.dissocPath(['items', 1], orig);
//=> { items: ['a', 'c'] }

orig;
//=> { items: ['a', 'b', 'c'] }

R.dissocPath(['items', '1'], orig);
//=> { items: { '0': 'a', '2': 'c' } }
Try It Yourself

How It Works

Path ['items', 1] clones the array without index 1. Path ['items', '1'] treats items like an object and omits the property named '1', so you get an object-like leftover with '0' and '2'. Pass a number for array indexes.

Example 5 — Curry, Map, assocPath

Fill the path to get a function of one object. Map it over rows. assocPath can put the nested key back.

Ramda
const dropName = R.dissocPath(['user', 'name']);
const stripped = dropName({ user: { name: 'Ada', city: 'Paris' } });

stripped;
//=> { user: { city: 'Paris' } }

R.map(dropName, [{ user: { name: 'Ada' } }, { user: { name: 'Bo' } }]);
//=> [{ user: {} }, { user: {} }]

R.assocPath(['user', 'name'], 'Ada', stripped);
//=> { user: { city: 'Paris', name: 'Ada' } }
Try It Yourself

How It Works

Because dissocPath is arity 2, filling path leaves a function of one object, ready for R.map and R.pipe. assocPath is the docs’ see-also inverse: same path array, a value, a clone with that nested key set. Key order on the restored object can differ because the new key is written last.

Browser Support

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

✓ Ramda 0.11.0+ · Any JS runtime

Ramda.js R.dissocPath()

Load Ramda 0.11.0 or later via CDN or npm, then call R.dissocPath with a path array and an object. No extra browser API is required.

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

Bottom line: Safe in any project that includes Ramda 0.11.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.dissocPath(path, obj) returns a shallow clone of obj without the property at the tail of path. Sibling keys along that path stay. Added in v0.11.0. The original object is not mutated.
R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}) is {a: {b: {}}}. Key c is gone. The empty b object remains.
No. It returns a new object at every level of the path. Nodes not on the path are copied by reference, so the clone is shallow except along that path.
dissoc drops one top-level key. dissocPath walks an array of keys such as ['user', 'name']. assocPath is the inverse: it sets a nested path on a clone.
You still get a clone of the existing tree. No error. An empty path returns the original object reference. null or undefined as obj is returned as-is.
No. R.dissocPath is a stable Ramda object helper from v0.11.0. It is not deprecated, experimental, or non-standard.

Continue to R.eqProps()

Learn how to compare one named property on two objects using Ramda R.eqProps().

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