Skip to content

Instantly share code, notes, and snippets.

@Daniel-Hug
Created October 17, 2017 06:36
Show Gist options
  • Save Daniel-Hug/3d984d4456b645c53a70d10e50db2f7f to your computer and use it in GitHub Desktop.
Save Daniel-Hug/3d984d4456b645c53a70d10e50db2f7f to your computer and use it in GitHub Desktop.
JS function: check if two objects have the same properties
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