Skip to content

Instantly share code, notes, and snippets.

@gilly3
Last active August 29, 2015 14:06
Show Gist options
  • Save gilly3/c511a8051993dd01b4fb to your computer and use it in GitHub Desktop.
Save gilly3/c511a8051993dd01b4fb to your computer and use it in GitHub Desktop.
Not perfect, but maybe a decent start at a generic object equality by value javascript function
Object.prototype.equals = function(o) {
var properties = Object.keys(this);
var eq = JSON.stringify(properties.sort()) === JSON.stringify(Object.keys(o).sort());
while (eq && properties.length) {
var p = properties.pop();
eq = this[p] === o[p];
}
return eq;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment