Implementing an identical JSON.stringify
Darien Valentine
valentinium at gmail.com
Sun Aug 5 02:14:16 UTC 2018
Is this a question about how/if one could replicate its behavior in theory
from ES code, or are you suggesting a change to the existing behavior for
these exotic cases?
Assuming the former:
The relevant steps are [here](
https://tc39.github.io/ecma262/#sec-serializejsonproperty). The
`instanceof` a value isn’t significant in this algorithm, just its slots
(if it is an object) or its primitive type. So one can handle number and
string by leveraging branded checks as you’ve shown — nothing more is
needed than branded methods and typeof to manage that one.
However it is ultimately not possible to replicate because there is no
possible brand test for [[BooleanData]].
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180804/33b57b2f/attachment.html>
More information about the es-discuss
mailing list