Why Number(symbol) crashes?

Kris Siegel krissiegel at gmail.com
Tue Oct 11 15:59:57 UTC 2016

Symbol is such an oddball; similar to this if you do Symbol() + "" it will
also throw an exception unlike all other built-ins. Granted I have no idea
what a string representation of Symbol *really* would be but no other built
in type behaves the way Symbol does.

I do think Number(Symbol()) should return NaN though. I'd like to know why
this didn't happen.

On Tue, Oct 11, 2016 at 2:07 AM, medikoo <medikoo+mozilla.org at medikoo.com>

> I was searching the archived but wasn't able to find the answer.
> What's the reasoning behind having Number(symbol) crash instead of
> returning
> NaN (as it's in case all other non-coercible values?). It feels not
> consistent.
> If someone can point me to some discussion that provided the reasoning I'd
> be grateful
> --
> View this message in context: http://mozilla.6506.n7.nabble.
> com/Why-Number-symbol-crashes-tp359554.html
> Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at
> Nabble.com.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20161011/f372db67/attachment.html>

More information about the es-discuss mailing list