javascript - How to check if an object contains another object? -
var person = { "name" : "bronn", "description" : { "occupation" : "guardian knight", "age" : 52 } } for(var key in person){ if(person[key] == /*contains json object */){ //do } }
i want loop person , check if value contains single data or object.
you can use map function or loop , can check using typeof method in javascript.
var person = { "name": "bronn", "description": { "occupation": "guardian knight", "age": 52 } } object.keys(person).map(item => { if (typeof person[item] == 'object') { // logic here... console.log(person[item]); } });
Comments
Post a Comment