js subject to a type of binary objects into common

jsonToArray function (Nodes) { 
  the let R & lt = []
   IF (Array.isArray (Nodes)) {
     for (the let I = 0 , L = nodes.length; I <L; I ++ ) { 
      r.push (Nodes [I]) // get the data into a new array for each 
      IF (Array.isArray (Nodes [I] [ ' children ' ]) && Nodes [I] [ ' children ' ] .length> 0 ) {
         // if present children recursively call, the spliced data to the new array, and deletes the Children 
        R & lt r.concat = (jsonToArray (Nodes [I] [ ' Children ' ])) 
      } 
      delete Nodes [I] [ 'children']
    }
  }
  return r
}

 

Guess you like

Origin www.cnblogs.com/Hhuizi/p/11609394.html