Skip to content

Instantly share code, notes, and snippets.

@miya2000
Created October 11, 2009 04:07
Show Gist options
  • Save miya2000/207394 to your computer and use it in GitHub Desktop.
Save miya2000/207394 to your computer and use it in GitHub Desktop.
(function(){
function X(a, b) {
this.a = a;
this.b = b;
}
var a = new X(1, 1);
var b = new X(1, 1);
alert('[first] ' + (a == b));
X.prototype.toString = function() {
return 'a:[' + this.a + '] b:[' + this.b + ']';
};
alert('[toString] ' + (a == b));
X.prototype.valueOf = function() {
return 'a:[' + this.a + '] b:[' + this.b + ']';
};
alert('[valueOf] ' + (a == b));
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment