How to loop through a javascript object and check each key exists in a separate multidimensional object
- by Paul Atkins
I have 2 javascript objects and I am trying to loop through one object and check whether the key exists in a second multidimensional object going one level deeper each time.
Here are the two objects
var check = {'scope':'instance', 'item':'body', 'property': 'background'};
var values = {'instance': {'body' : {'background': '000000'}}};
b.map(check, function(key){
console.log(values[key]);
});
How am I able to check 1 level deeper in the values object each time? What I am trying to do is check the values object as follows:
1st values['instance']
2nd values['instance']['body']
3rd values['instance']['body']['background']
Thanks