UNPKG

@extra-array/get-path

Version:

Gets value at path in a nested array.

59 lines (44 loc) 1.74 kB
Gets value at path in a nested array. [:package:](https://www.npmjs.com/package/@extra-array/get-path) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/get-path) [:vhs:](https://asciinema.org/a/343813) [:moon:](https://www.npmjs.com/package/@extra-array/get-path.min) [:scroll:](https://unpkg.com/@extra-array/get-path/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [get], [getAll], [getPath].<br> > Similar: [hasPath], [getPath], [setPath$], [removePath$].<br> > Similar: [get], [set], [remove]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.getPath(x, p); // x: a nested array // p: path ``` ```javascript 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 ``` <br> <br> ## References - [ArrayList.get: Java](https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html#get(int)) - [_.nth: lodash](https://lodash.com/docs/4.17.15#nth) - [Array.at: sugarjs](https://sugarjs.com/docs/#/Array/at) [get]: https://github.com/nodef/extra-array/wiki/get [getAll]: https://github.com/nodef/extra-array/wiki/getAll [getPath]: https://github.com/nodef/extra-array/wiki/getPath [hasPath]: https://github.com/nodef/extra-array/wiki/hasPath [setPath$]: https://github.com/nodef/extra-array/wiki/setPath$ [removePath$]: https://github.com/nodef/extra-array/wiki/removePath$ [set]: https://github.com/nodef/extra-array/wiki/set [remove]: https://github.com/nodef/extra-array/wiki/remove