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)
Call
What 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
Parameter
Description
path
Required. Array. Keys to walk. Strings (and symbols) are object keys. Integers are array indexes. An empty path returns obj itself.
obj
Required. Object or Array. The source. It is never mutated. null and undefined are returned as-is.
Return Value
Return Value
Description
Object or Array
A 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.
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.
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.
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.
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.
Compatibility
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 ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll 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.