Skip to content

Instantly share code, notes, and snippets.

@josephmosby
Created February 23, 2015 20:17
Show Gist options
  • Save josephmosby/77b324e39611e8608ce5 to your computer and use it in GitHub Desktop.
Save josephmosby/77b324e39611e8608ce5 to your computer and use it in GitHub Desktop.
Low-grade check for equality between two JavaScript objects
Object.prototype.equals = function(object) {
if (Object.keys(this).length != Object.keys(object).length) {
return false;
}
for (var i = 0; i < Object.keys(this).length; i++) {
if (this[Object.keys(this)[i]] != object[Object.keys(object)[i]]) {
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment