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

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -