Having a dynamic foo
object with the possibility of nested parent
objects raises the question of how to effectively:
1) Determine the last object that has a parent?
2) Create an array containing all nested parent objects along with the initial obj (foo.obj)?
foo: {
caption: "Italian",
code: "",
id: 17,
parent: {
caption: "Restaurants",
code: "",
id: 9,
parent: {
caption: "Food and Drink",
code: "food_and_drink",
id: 1,
parent: ""
}
}
};
Would implementing a while
loop be appropriate for this task?