> Le 5 août 2018 à 05:07, Claude Pache <[email protected]> a écrit :
> 
> 
> 
>> Le 5 août 2018 à 04:50, Claude Pache <[email protected] 
>> <mailto:[email protected]>> a écrit :
>> 
>> 
>> 
>>> Le 5 août 2018 à 01:43, Michael Theriot <[email protected] 
>>> <mailto:[email protected]>> a écrit :
>>> 
>>> Try `Number.prototype.valueOf.call(obj)`: it will throw a TypeError if and 
>>> only if `obj` has no [[NumberData]] internal slot. Ditto for String, 
>>> Boolean and Symbol.
>>> 
>>> I already mention this and demonstrate why it is not sufficient in my 
>>> example.
>>> 
>>> Reiterated plainly:
>>> ```js
>>> JSON.stringify(Reflect.construct(Number, [], Number)); // "0"
>>> JSON.stringify(Reflect.construct(Number, [], String)); // TypeError
>>> JSON.stringify(Reflect.construct(Number, [], Object)); // null
>>> ```
>> 
>> Per spec, the three expressions should produce `"0"`, as the three objects 
>> have a [[NumberData]] internal slot (step 4 of [1]). I guess there is some 
>> discrepancy between implementation and spec for those exotic edge cases?
>> 
>> [1]: https://tc39.github.io/ecma262/#sec-serializejsonproperty 
>> <https://tc39.github.io/ecma262/#sec-serializejsonproperty>
>> 
>> —Claude
>> 
> 
> I see that there is a difference in this algorithm between the current spec 
> and ES 2015 for that particular step. From my tests, current stable Firefox 
> and Safari (other browsers not tested) still follow the old algorithm.
> 
> —Claude
> 
> 
Nevrmind, forget the previous message. The algorithm does indeed somewhat 
strange here.

—Claude

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to