Skip to content

Instantly share code, notes, and snippets.

@lusan
Created February 19, 2017 21:14
Show Gist options
  • Save lusan/5745535e445e06b67ee122d9c921c5cd to your computer and use it in GitHub Desktop.
Save lusan/5745535e445e06b67ee122d9c921c5cd to your computer and use it in GitHub Desktop.
/* Module to check if two objects are euqal*/
var isObjectsEqual = function(a, b) {
var aProp = Object.getOwnPropertyNames(a);
var bProp = Object.getOwnPropertyNames(b);
if(aProp.length != bProp.length) {
console.log("Objects are not equal");
return false;
}
for(var i = 0; i < aProp.length; i++) {
var propName = aProp[i];
if(a[propName] !== b[propName] ) {
console.log("Objects are not equal");
return false;
}
}
console.log("Objects are equal");
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment