I managed to find a bug (maybe not bug, but huge pain in the ass) that took an impossibly long time to track down, and can replicate it using the REPL (NodeJS):
> o = {};
{}
> JSON.stringify(o)
'{}'
> o.n = 10
10
> JSON.stringify(o)
'{"n":10}'
> o.n = Infinity;
Infinity
> JSON.stringify(o)
'{"n":null}'
> null == Infinity
false
> null === Infinity
false
> typeof 10
'number'
> typeof Infinity
'number'
When you put Infinity
into JSON it becomes null
, despite Infinity
being a number
type. Normally who cares, but when -Infinity
, NaN
, 0
, and Infinity
all have special meaning in the context of your application (machine learning), it's pretty important to be able to transmit special numbers as plain JSON without resorting to stuffing and unstuffing it into a string every time.
String stuffing requires an extra type check for every access, then a switch case string comparison against all special number types, followed by a reallocation to the actual special number type. Once isn't bad, 40 or 50 trillion times a minute is where you really start to curse the ECMA gods.
Am I missing something, or is this just one of those things ECMA considered not so important?