Why does typeof NaN return 'number'?

前端 未结 21 1233
误落风尘
误落风尘 2020-11-22 05:38

Just out of curiosity.

It doesn\'t seem very logical that typeof NaN is number. Just like NaN === NaN or NaN == NaN returning

21条回答
  •  遇见更好的自我
    2020-11-22 06:18

    An example

    Imagine We are converting a string to a number:

    Number("string"); // returns NaN
    

    We changed the data type to number but its value is not a number!

提交回复
热议问题