Why Number(symbol) crashes?
allen at wirfs-brock.com
Fri Oct 14 23:22:50 UTC 2016
> On Oct 14, 2016, at 11:02 AM, Claude Pache <claude.pache at gmail.com> wrote:
>> Le 11 oct. 2016 à 11:07, medikoo <medikoo+mozilla.org at medikoo.com> a écrit :
>> 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
>> If someone can point me to some discussion that provided the reasoning I'd
>> be grateful
> I believe that the reason of the inconsistency is more an accident of history in the development of ES6 than a well-reasoned design decision. Here is my understanding:
No this was an intentional design decision. There is no obvious or natural Number value corresponding to symbol values. Rather than inventing some arbitrary conversion rule (for example producing NaN) TC39 choose to throw an exception for such conversions as they are a clear manifestation of some sort of program bug.
More information about the es-discuss