Skip to content

getPath

Subhajit Sahu edited this page Feb 4, 2021 · 8 revisions

Gets value at path in nested lists. 📦 😺 🏃 📼 🌔 📜 📰 📘

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


lists.getPath(x, p);
// x: nested lists
// p: path
const lists = require('extra-lists');

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

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

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


References

Clone this wiki locally