Is NaN equal to NaN?

前端 未结 8 2060
遇见更好的自我
遇见更好的自我 2020-11-27 05:22
parseFloat(\"NaN\")

returns \"NaN\", but

parseFloat(\"NaN\") == \"NaN\"

returns false. Now, that\'s probably a go

8条回答
  •  野性不改
    2020-11-27 05:46

    In ECMAScript 6 Object.is() is an enhancement of ===. This method accepts two arguments and returns true if the values are equivalent.And the two values are considered equivalent when they are of the same type and have the same value. That's the reason because console.log(Object.is(NaN, NaN))--> TRUE

提交回复
热议问题