I have the following javascript array of objects main array is root have children
Array(2) [
{ id: "3", children: [] },
{ id: "8", children: [{ id: "476", children: [] }] }
]
I want to print all with loop
I try this code
let idx= [];
for(var i = 0; i < root.length; i++){
idx[i]=root[i].id;
}
console.log(idx);
this code print root ids but I want all root and children ids