1

I can't find any information on this, but I have the following question: for a number f in javascript that's not some NaN, infinite value, or negative zero, do the following statements always evaluate to true:

JSON.parse(JSON.stringify(f)) === f;

and

Number(f.toString()) === f;

With more nuance, is this required by ECMAScript standards? And does this de facto hold among none/some/all the various runtimes?

jhanschoo
  • 1,236
  • 13
  • 15
  • Yes, this is guaranteed. They might differ in the particular string through which they roundtrip, but it is required to work for all strings allowed by the specification. – Bergi Jul 13 '21 at 12:13

0 Answers0