I am Trying to create nested group of my javascript raw object.
item=[ {name:'Root1',id:1,parentId:null}, {name:'Root2',id:2,parentId:null}, {name:'Root3',id:4,parentId:null}, {name:'Root1.1',id:4,parentId:1}, {name:'Root1.1.1',id:5,parentId:4}, {name:'Root4',id:6,parentId:null} ]; this is my raw data,
I want this data in format some like bellow
var modified= [ { title:Root1, id:1, chields: { title:'Root 1.1', id:4, clields: { title:'Root 1.1.1', id:5, chield: { title:'New', id:null } } } } ];