1var myString = "Item1";
2
3var jsObject =
4{
5 Item1:
6 {
7 "apples": "red",
8 "oranges": "orange",
9 },
10 Item2:
11 {
12 "bananas": "yellow",
13 "pears": "green"
14 }
15};
16
17var keys = Object.keys(jsObject); //get keys from object as an array
18
19keys.forEach(function(key) { //loop through keys array
20 console.log(key, key == myString)
21});