Skip to content

getPath

Subhajit Sahu edited this page Jun 28, 2020 · 11 revisions

Gets value at path in a nested array. 🏃 📼 📦 🌔 📒

Alternatives: get, getAll, getPath.
Similar: hasPath, getPath, setPath$, removePath$.
Similar: get, set, remove.

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

var x = [[2, 4], 6, 8];
array.getPath(x, [1]);
// 6

array.getPath(x, [0, 1]);
// 4

array.getPath(x, [0, 1, 2]);
// undefined

references

Clone this wiki locally