Why is isNaN(null) == false in JS?

后端 未结 8 1457
迷失自我
迷失自我 2020-11-28 05:07

This code in JS gives me a popup saying \"i think null is a number\", which I find slightly disturbing. What am I missing?

8条回答
  •  一向
    一向 (楼主)
    2020-11-28 06:02

    Note:

    "1" == 1 // true
    "1" === 1 // false
    

    The == operator does type-conversion, while === does not.

    Douglas Crockford's website, a Yahoo! JavaScript evangelist, is a great resource for stuff like this.

提交回复
热议问题