Imagine a scenario where I have an array filled with data. Each element in this array is an object that could contain:
- an id
- some additional data
- a property (let's name it
sub
) which may hold an array of objects with the same properties (including thesub
property).
In essence, this represents nested data structures where each object can potentially store more objects within itself.
I am aware that traversing this data tree typically involves using a recursive function like the one found here. However, I am curious if libraries such as underscore or angular offer any alternatives to simplify this process and allow me to perform operations like
data.findNestedById(12345, "sub");
without dealing with excessive boilerplate code.