language behaviors to newcomers.
--
View this message in context:
http://mozilla.6506.n7.nabble.com/Why-Number-symbol-crashes-tp359554p359653.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at
Nabble.com.
___
es-discuss mailing
To be honest, introducing new throw-on-invalid value behaviour to existing
function that didn't throw before looks rather like a bad design for me.
Personally I wouldn't abandon accept-anything behaviour of Number, but
rather add method Number.from that will throw on all values that shouldn't
be
> On Oct 14, 2016, at 11:02 AM, Claude Pache wrote:
>
>
>> Le 11 oct. 2016 à 11:07, medikoo a écrit :
>>
>> I was searching the archived but wasn't able to find the answer.
>>
>> What's the reasoning behind having Number(symbol) crash
> Le 11 oct. 2016 à 11:07, medikoo 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
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
sh 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.na
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
10 matches
Mail list logo