1 var obj1={"id" : 1, "name" : "java"},
2 obj2={"id" : 1, "name" : "java4you", "gender" : "male"};
3
4 function compare(obj1, obj2) {
5 let obj = {};
6 for(let k in obj1) {
7 if(obj1[k] !== obj2[k]) {
8 obj = Object.assign({}, obj1, obj1[k] = obj2[k]);
9 }
10
11 }
12 return obj;
13 }