let obj1 = {a:5, b:6}, obj2 = {a:8, b:7};
let keysObj1 = Object.keys(obj1), keysObj2 = Object.keys(obj2);
for (let i = 0; i < keysObj1.length; i ++) {
if (keysObj1[i] === keysObj2[i] && obj1[keysObj1[i]] === obj2[keysObj2[i]]) {
console.log(keysObj1[i], keysObj2[i], obj1[keysObj1[i]], obj2[keysObj2[i]]);
}
}
// -> a, a, undefined, undefined
P.S. I am aware of alternative methods to compare objects; I just wanted to investigate why this particular approach didn't yield the expected results.