Skip to content
Advertisement

Tag: nested

Access dynamic nested key in JS object

I have an array like [‘animals’, ‘cats’, ‘cute’, ‘fast’, ‘small’, …], and want to access nested keys of the object like Usually I would write object[‘animals’][‘cats’][‘cute’][‘fast’][‘small’].. The problem is that keys and the number of levels are dynamic (so I can get objects with 2 nested levels or 50), so I have no idea how it can be done Thanks

Convert array of flat objects to nested objects

I have the following array (that’s actually coming from a backend service): where Item is: In order to be compatible with a component that displays a tree (folder like) view, it needs to be transformed into: where NestedItem is: All I’ve tried so far is something like: But this only gets the first level of children, of course (direct children

Remove duplicates of array from another array, JavaScript

How can i remove duplicated arrays in this data structure? [![enter image description here][1]][1] I got this: with: I need to reduce data, remove duplicated arrays and provide result to sankey graf. jsonData elements contain much more data and structure of each left, center and right side is a little bit diffrent. [1]: http://i.stack.imgur.com/1MvXz.png Answer You could filter them:

Advertisement