Created
October 17, 2017 06:36
-
-
Save Daniel-Hug/3d984d4456b645c53a70d10e50db2f7f to your computer and use it in GitHub Desktop.
JS function: check if two objects have the same properties
This file contains 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
function getProperties(obj) { | |
var newObj = {}; | |
for (var key in obj) { | |
newObj[key] = true; | |
} | |
return newObj; | |
} | |
function haveSameProperties(a, b) { | |
return JSON.stringify(getProperties(a)) === JSON.stringify(getProperties(b)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment