Reputation: 8297
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.
Upvotes: 0
Views: 6604
Reputation: 4003
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)
})
}
})
Upvotes: 1