Implicit coercion of Symbols
Boris Zbarsky
bzbarsky at mit.edu
Sat Jan 3 19:24:56 PST 2015
On 1/3/15 9:41 PM, Alex Kocharin wrote:
> function log(anything) {
> process.stdout.write(new Date().toJSON() + ' - ' + anything + '\n')
> }
> ```
> Right now it'll never throw. Well, unless you override `.toString()` to
> throw, which I've never seen to be done intentionally.
Just to nitpick, try:
console.log("" + HTMLAnchorElement.prototype);
in your favorite browser and watch it throw precisely for this reason.
Or load
data:text/html,<iframe src="http://www.ecma-international.org/"></iframe>
and try:
console.log("" + frames[0]);
> With throwing Symbols we'll have innocuous-looking code which will cause
> an exception.
The innocuous-looking code will totally cause exceptions in the wild
today depending on what you pass to it.
-Boris
More information about the es-discuss
mailing list