Skip to content

Instantly share code, notes, and snippets.

@brianleroux
Created April 2, 2010 23:17
Show Gist options
  • Save brianleroux/353862 to your computer and use it in GitHub Desktop.
Save brianleroux/353862 to your computer and use it in GitHub Desktop.
var foo = {
toString: function () {
return 5;
},
valueOf: function () {
return "foo";
}
};
alert(foo.toString() + 1); // 6 (bad!)
alert(foo + 1); // "foo1" (no good!)
alert(+foo); // NaN (the worst!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment