Created
September 28, 2018 18:56
-
-
Save jordanhudgens/18913a642cd7c511830e7a73b880fa7d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isEqual = (obj1, obj2) => { | |
const obj1Keys = Object.keys(obj1); | |
const obj2Keys = Object.keys(obj2); | |
if (obj1Keys.length !== obj2Keys.length) { | |
return false; | |
} | |
for (let objKey of obj1Keys) { | |
if (obj1[objKey] !== obj2[objKey]) { | |
return false; | |
} | |
} | |
return true; | |
}; | |
const obj1 = { | |
name: "Kristine", | |
age: 13 | |
}; | |
const obj2 = { | |
name: "Kristine", | |
age: 13 | |
}; | |
obj1 == obj2; // false | |
isEqual(obj1, obj2); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment