algorithm - iterating through array of nested objects with javascript/lodash -


I have an array of objects representing the nested navigation list. [{Name: 'one', link: 'blah / blah', pages: [[name: 'a' link: 'blah / blah', pages: []}, {Name: 'A B' link: 'Blah / Blah', Page: []}, {Name: 'A' link: Faucet, Page: [{Name: 'A CI' link: 'Blah / Blah', Page: []}]}]}]

The first level of objects can be a link and a page in which the nested object will have a link or a page. I can not accept the limit of nesting depth. I need an object for each state in which its name, its link if it exists and all of its parents include my current solution does not account for more than 3 levels of nesting and for each layer Adding support is laborious.

I need to be able to search the array as a result of that object, it makes a difference for the solution.

I need a Javascript solution, but also (and would like to) use the work contained in the junk library

  var arrPages = [{name: "post-text" itemprop = "text"> 

'one', link: 'blah / Bla ', pages: [[Name:' A ', Link:' Blah / Blah ', Pages: []}, {Name:' A B ', Link:' Blah / Bla ', Pages: []} , {Name: 'one c', link: tap, pages: [{name: 'one c me', link: 'blah blah', pages: []}]}]}}]; Function recursive function (collection) {_.each (collection, function (model) {console.log (model); if (model.page.length> gt; l) {recursive function (model pages)}}}); }; RecursiveFunction (arrPages);

Is it you need, or do you particularly want anything? Depending on your previous comments, if you need something else then I'm a little confused

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -