Created
February 23, 2015 20:17
-
-
Save josephmosby/77b324e39611e8608ce5 to your computer and use it in GitHub Desktop.
Low-grade check for equality between two JavaScript objects
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
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