Skip to content

Instantly share code, notes, and snippets.

@koron
Created May 30, 2014 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koron/2a2e262052f1de865708 to your computer and use it in GitHub Desktop.
Save koron/2a2e262052f1de865708 to your computer and use it in GitHub Desktop.
Boolean.prototype.toString = function() { return 'foo'; }
console.log(false);
console.log(false.toString());
console.log('' + false)
function Bar() {}
Bar.prototype.toString = function() { return 'bar'; }
var b = new Bar();
console.log(b);
console.log(b.toString());
console.log('' + b);
@koron
Copy link
Author

koron commented May 30, 2014

ECMAScript の仕様 9.8 ToString によるものと判明した。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment