3
in this script, which compares objects in javascript, even if I pass equal values (to my understanding, but which all indicates is wrong), the return remains false. someone could help me better understand this concept?
let deepEqual = (a, b) => {
let aKeys = Object.keys(a);
let bkeys = Object.keys(b);
if (aKeys.length !== bkeys.length) {
return false
}
let equals = aKeys.some((chave) => {
return a[chave]!== b[chave]
});
return !equals
}
let obj = {here: {is: "an"}, object: 2};
let obj2 = {here: {is: "an"}, object: 2};
let obj3 = obj2;
console.log(deepEqual(obj, obj));
// true
console.log(deepEqual(obj, obj2));
// false
console.log(deepEqual(obj2, obj3));
// true
console.log(deepEqual(obj, {here: {is: "an"}, object: 2}));
// false
thanks ;)