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 recursive approach seems best, something like this:
function recursiveIteration(object) {
for (var property in object) {
if (object.hasOwnProperty(property)) {
if (typeof object[property] == "object"){
recursiveIteration(object[property]);
}else{
//found a property which is not an object, check for your conditions here
}
}
}
}
This is a working fiddle