> Le 5 août 2018 à 01:43, Michael Theriot <michael.lee.ther...@gmail.com> 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


_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to