-
Notifications
You must be signed in to change notification settings - Fork 1
getPath
Subhajit Sahu edited this page Dec 5, 2022
·
10 revisions
Get value at path in a nested map.
Similar: get, getAll, getPath, setPath$, removePath$.
Similar: get, set, remove.
function getPath(x, p)
// x: a nested map
// p: path
const map = require('extra-map');
var x = new Map([['a', 2], ['b', 4], ['c', 6]]);
var y = new Map([['x', x], ['e', 10], ['f', 12]]);
map.getPath(y, ['e']);
// → 10
map.getPath(y, ['x', 'b']);
// → 4
map.getPath(y, ['x', 'b', 'c']);
// → undefined