Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // примерная структура
- const items = [
- {
- _path: [0],
- title: "[0]",
- children:[
- {
- _path: [0,0],
- title: "[0,0]",
- children: []
- },
- {
- _path: [0,1],
- title: "[0,1]",
- children: [
- {
- _path: [0,1,0],
- title: "[0,1,0]",
- children: [/* ... */]
- }
- ]
- },
- ]
- },
- /* ... */
- ]
- function getElement(tree, path) {
- return getElement(tree[path.shift()].children, path);
- }
Add Comment
Please, Sign In to add comment