Skip to content

Instantly share code, notes, and snippets.

@ibolmo
Created January 5, 2012 17:53
Show Gist options
  • Select an option

  • Save ibolmo/1566356 to your computer and use it in GitHub Desktop.

Select an option

Save ibolmo/1566356 to your computer and use it in GitHub Desktop.
Object.isStrictlyEquals
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