Created
January 5, 2012 17:53
-
-
Save ibolmo/1566356 to your computer and use it in GitHub Desktop.
Object.isStrictlyEquals
This file contains hidden or 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
| var equals = function(value, i){ | |
| return (i in this) && Object.equals(value, this[i]); | |
| }; | |
| Object.extend({ | |
| 'equals': function(first, second){ | |
| if (first === second) return true; | |
| var type = typeOf(first); | |
| if (type !== typeOf(second)) return false; | |
| if (type == 'regexp') return String(first) == String(second); | |
| if (type == 'date') return first.getTime() == second.getTime(); | |
| if (type == 'arguments') first = Array.from(first); | |
| if (first.length !== second.length) return false; | |
| return ((type == 'object') ? Object.every : Array.every)(first, equals, second); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment