-
Notifications
You must be signed in to change notification settings - Fork 3
getPath
Subhajit Sahu edited this page Jun 28, 2020
·
3 revisions
Gets value at path in a nested object. 🏃 📼 📦 🌔 📒
Alternatives: get, getAll, getPath.
Similar: hasPath, getPath, setPath$, removePath$.
Similar: get, set, remove.
object.getPath(x, p);
// x: a nested object
// p: pathconst object = require('extra-object');
var x = {a: {b: 2, c: 3}, d: 4};
object.getPath(x, ['d']);
// 4
object.getPath(x, ['a', 'b']);
// 2
object.getPath(x, ['a', 'b', 'c']);
// undefined