I have a json object
user = { name: "somename", personal : { age:"19",color:"dark"}}
_.each(user,function(value){ if(isNaN(value){console.log(value)} )
How to get to the nested object value.
I have a json object
user = { name: "somename", personal : { age:"19",color:"dark"}}
_.each(user,function(value){ if(isNaN(value){console.log(value)} )
How to get to the nested object value.
Something like this will work. If you expect even more deeply nested objects, then create a recursive function. _.isObject(val)
is the key here.
_.each( {name: "somename", personal : { age:"19",color:"dark"}}, function(val) {
if (_.isObject(val)) {
_.each(val, function(v) {
console.log(v)
})
}
})