Ramda’s R.dissoc() answers a simple question: give me a copy of this object without that property. You pass the key, then the object. You get a new object. The original is never mutated. If the key is there, it is omitted. If it is missing, the clone still holds every original property.
The official sample is the whole idea. R.dissoc('b', {a: 1, b: 2, c: 3}) is {a: 1, c: 3}. Native JavaScript’s cousin is rest syntax: const { b, ...rest } = obj. That is data-first. dissoc is data-last, so R.dissoc('password') is already a function of one object — ready for R.map or R.pipe. Need to drop many keys? That is R.omit. Need a nested key? That is R.dissocPath. Need to put a key back? That is R.assoc. Lodash _.omit(obj, 'b') is data-first; Ramda clones and wants the key first.
Syntax
Call R.dissoc. Start with this line.
Ramda
R.dissoc(prop, obj)
Call
What it does
R.dissoc(prop, obj)
Primary signature.
R.dissoc(...)
Call the object helper.
Prefer import { dissoc } from "ramda" when you want a named import.
Library declarations
Ramda
R.dissoc(prop, obj)
Parameters
Parameter
Description
prop
Optional. String (or Int). The property name to omit. An integer key on an array removes that index on a new array.
obj
Required. Object or Array. The source. It is never mutated. A new object (or array) is returned.
Return Value
Return Value
Description
Object or Array
A shallow clone without prop. Nested objects stay shared by reference. A missing key still yields a clone of the remaining properties.
Ramda Examples
📚 Getting Started
The official Ramda sample, then the same object so you can see the source is untouched and a missing key is safe.
Example 1 — Official Object
One key is omitted on a clone. The leftover is every original property except b.
The clone is missing b. orig.b stays 2 because dissoc never uses delete on the source. A missing z is skipped during the copy, so you still get a new object with a, b, and c.
📈 Practical Patterns
omit and assoc, then a shallow nested copy versus dissocPath, then a curried helper and an array index.
Example 3 — vs omit and assoc
omit with one key matches dissoc. omit with two keys drops both. assoc is the inverse: putting b back restores the object.
The docs point at omit for several keys and assoc for the opposite edit. Key order on the restored object can differ because assoc writes b last. Values match.
Example 4 — Shallow Copy vs dissocPath
Nested objects are shared by reference after dissoc. Nested deletes belong to dissocPath, which clones along the path.
dissoc copied the user pointer, then skipped role. Changing copy.user.name would also change orig.user.name. dissocPath clones the user object so name can disappear on a new tree. That is the next Object helper.
Example 5 — Curry, Map, Arrays
Fill the key to get a function of one object. Map it over rows. An integer key on an array removes that index on a new array.
Because dissoc is arity 2, filling prop leaves a function of one object, ready for R.map and R.pipe. Integer keys on arrays go through the array branch: a new array with that index gone. A string '1' is a property name, not an index. For a slice of items, List R.remove is the named cousin.
Compatibility
Browser Support
R.dissoc() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.10.0+ · Any JS runtime
Ramda.js R.dissoc()
Load Ramda 0.10.0 or later via CDN or npm, then call R.dissoc with a key and an object. No extra browser API is required.
100%With Ramda 0.10.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.dissoc()Universal
Bottom line: Safe in any project that includes Ramda 0.10.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.dissoc(prop, obj) returns a shallow clone of obj without prop. If the key is missing, the clone still has every original property. Added in v0.10.0. The original object is not mutated.
R.dissoc('b', {a: 1, b: 2, c: 3}) is {a: 1, c: 3}. Key b is gone. a and c stay.
No. It always returns a new object (or a new array when prop is an integer and obj is an array). Nested objects are copied by reference, so the clone is shallow.
dissoc drops one top-level key. omit drops a list of keys. assoc is the inverse: it sets a key on a clone. dissocPath drops a nested path such as ['user', 'name'].
You still get a clone. No error. The leftover looks like the original properties without that missing name.
No. R.dissoc is a stable Ramda object helper from v0.10.0. It is not deprecated, experimental, or non-standard.