📅  最后修改于: 2022-03-11 15:02:33.160000             🧑  作者: Mango
var obj1={"id" : 1, "name" : "java"},
obj2={"id" : 1, "name" : "java4you", "gender" : "male"};
function compare(obj1, obj2) {
let obj = {};
for(let k in obj1) {
if(obj1[k] !== obj2[k]) {
obj = Object.assign({}, obj1, obj1[k] = obj2[k]);
}
}
return obj;
}