NaN == NaN, False?

Before ECMAScript Edition 5, some built-in values such as undefined, Infinity and NaN are not read-only. So if you reassign NaN with a new number, in this case NaN can be equal to NaN.

NaN == NaN; //false
NaN = 1;
NaN == NaN; //true

The people who were making the specs seem have found this issue, and fixed it in edition 5.

I was curious what values were read-only by design in the ECMAScript Edition 3. These are what I have found out:

  • Native prototypes, eg., Array.prototype, Function.prototype, Object.prototype, etc.
  • Special values in Math, eg., Math.E, Math.PI, Math.SQRT1_2, etc.
  • Special values in Number, eg., Number.MIN_VALUE, Number.MAX_VALUE, etc.
  • However, Number.NaN, which is same as NaN, is read-only too. So are Number.POSITIVE_INFINITY and Number.NEGATIVE.