whoops, sorry, I missed the earlier thread. disregard.
On Tue, Oct 11, 2016 at 5:53 PM, Jordan Harband wrote:
> I'm not sure what you're asking. `Number(Symbol())` throws a TypeError.
>
> Perhaps are you using a Symbol sham (that only partially is able to
> polyfill Symbols)?
I'm not sure what you're asking. `Number(Symbol())` throws a TypeError.
Perhaps are you using a Symbol sham (that only partially is able to
polyfill Symbols)?
In what browser/engine are you seeing `NaN`?
On Tue, Oct 11, 2016 at 11:37 AM, Raul-Sebastian Mihăilă <
raul.miha...@gmail.com> wrote:
How is NaN useful? Isn't it better to be explicit if you really want a
string?
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
In my opinion it's a bit incoherent that each object-coercible type behaves
differently when coercing symbols to it.
Symbols can be explicitly coerced to strings, but not implicitly:
```js
String(Symbol("abc")); // "Symbol(abc)"
Symbol("abc") + ""; // TypeError
```
Symbols can't be coerced to
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
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
6 matches
Mail list logo