Skip to content

removePath$

Subhajit Sahu edited this page Jun 28, 2020 · 3 revisions

Removes value at path in a nested object. 🏃 📼 📦 🌔 📒

Alternatives: remove, remove$, removePath$.
Similar: hasPath, getPath, setPath$, removePath$.
Similar: get, set, remove.

object.removePath$(x, p);
// x: a nested object (updated)
// p: path
// --> x
const object = require('extra-object');

var x = {a: {b: 2, c: 3}, d: 4};
object.removePath$(x, ['d'], 40);
// { a: { b: 2, c: 3 } }

x;
// { a: { b: 2, c: 3 } }

object.removePath$(x, ['a', 'b'], 20);
// { a: { c: 3 } }

object.removePath$(x, ['a', 'b', 'c'], 30);
// { a: { c: 3 } }

references

Clone this wiki locally