Is there are a way to recursively loop over all the nested properties of a JS/jQuery object?
For example, given this object
var x = {
'name': 'a',
'level': 1,
'children': [{
'name': 'b',
'level': 2,
'children': [{
'name': 'c',
'level': 3,
'children': [{
...
}]
}]},
...
}]
}
how could I loop over the objects named 'a' and their children, 'b' and their children, 'c' and their children, ad infinitum?