Skip to content

removePath$

Subhajit Sahu edited this page Dec 8, 2022 · 3 revisions

Remove value at path in a nested object.

Similar: hasPath, getPath, removePath$.
Similar: get, set, swap, remove.


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

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

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

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

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


References

Clone this wiki locally