I have a nested structure as below:
arr[3].title="a3";
arr[3].nextArr=[];
arr[2].title="a2";
arr[2].nextArr=arr[3];
arr[1].title="a1";
arr[1].nextArr=arr[2];
arr[0].title="a0";
arr[0].nextArr=arr[1];
like here!:
|_
|_
|_
As you see, I have one array called arr with four members.
How can I make four separated arrays from arr?
arrayOne=[{title:"a1"},{nextArr:[]}];
arraytwo=[{title:"a2"},{nextArr:[]}];
.
.
.
Update: I need this converts in my AngularJS controller.js. I get a response from server which contains an array as above. And I have to make it flat. The count of inner arrays are not constant. I didn't mention that because I didn't know the algorithm. But, according to answers, it seems Itt was better if I explained it more.
Result = {arr[title:"a0",nextArr:{title:"a1",nextArr:{title:"a2",nextArr:{......}}}]};