3 ms·
JSON doesn't support NaN or infinity, so most JS implementations emit null for NaN, +Inf, -Inf. In Node: > JSON.stringify({nan: 0/0, inf: 1/0, neginf:-1/0})
by tlb 8y ago
JSON doesn't support NaN or infinity, so most JS implementations emit null for NaN, +Inf, -Inf. In Node:
> JSON.stringify({nan: 0/0, inf: 1/0, neginf:-1/0})
'{"nan":null,"inf":null,"neginf":null}'
I'm not sure if throwing an exception is better or worse.
- eridius 8y agoOk, but the line I quoted wasn't about infinity, it was about numbers that were "too large", which I assume means bignums.