Skip to content

getPath

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

Get value at path in nested ilists.

Alternatives: get, getAll, getPath.
Similar: hasPath, getPath.
Similar: get, set, remove.


function getPath(x, p)
// x: nested ilists
// p: path
const xilists = require('extra-ilists');

var x = [['a', 'b', 'c'], [2, 4, 6]];
var y = [['x', 'e', 'f'], [x, 10, 12]];
xilists.getPath(y, ['e']);
// → 10

xilists.getPath(y, ['x', 'b']);
// → 4

xilists.getPath(y, ['x', 'b', 'c']);
// → undefined


References

Clone this wiki locally