📜  检查两个对象是否相等 javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:21.700000             🧑  作者: Mango

代码示例3
var myString = "Item1";

var jsObject = 
{
    Item1:
    {
        "apples": "red",
        "oranges": "orange",
    },
    Item2:
    {
        "bananas": "yellow",
        "pears": "green"
    }
};

var keys = Object.keys(jsObject); //get keys from object as an array

keys.forEach(function(key) { //loop through keys array
  console.log(key, key == myString)
});