Guest User

Untitled

a guest
Jun 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. // примерная структура
  2. const items = [
  3. {
  4. _path: [0],
  5. title: "[0]",
  6. children:[
  7. {
  8. _path: [0,0],
  9. title: "[0,0]",
  10. children: []
  11. },
  12. {
  13. _path: [0,1],
  14. title: "[0,1]",
  15. children: [
  16. {
  17. _path: [0,1,0],
  18. title: "[0,1,0]",
  19. children: [/* ... */]
  20. }
  21. ]
  22. },
  23. ]
  24. },
  25. /* ... */
  26. ]
  27.  
  28. function getElement(tree, path) {
  29. return getElement(tree[path.shift()].children, path);
  30. }
Add Comment
Please, Sign In to add comment