📅  最后修改于: 2022-03-11 14:55:58.727000             🧑  作者: Mango
function isEqual(firstObj, secondObj) {
const firstKeys = Object.keys(firstObj);
const secondKeys = Object.keys(secondObj);
if(firstKeys.length !== secondKeys.length){
return false;
}
return firstKeys.every(function (key) {
return firstObj[key] === secondObj[key];
})
}
const first = {
property: "value",
anotherProperty: "another value"
};
const second = {
property: "value",
anotherProperty: "another value"
};
const third = {
property: "value",
anotherProperty: "yet another value"
};
isEqual(first, second); // true
isEqual(second, third); // false