1var person1={first_name:"bob"};
2var person2 = {first_name:"bob"};
3
4//compare the two object
5if(JSON.stringify(person1) === JSON.stringify(person2)){
6 //objects are the same
7}
8
1function shallowEqual(object1, object2) {
2 const keys1 = Object.keys(object1);
3 const keys2 = Object.keys(object2);
4
5 if (keys1.length !== keys2.length) {
6 return false;
7 }
8
9 for (let key of keys1) {
10 if (object1[key] !== object2[key]) {
11 return false;
12 }
13 }
14
15 return true;
16}