Is NaN falsy? Why NaN === false returns false

前端 未结 7 817
走了就别回头了
走了就别回头了 2020-12-13 18:43
  1. Why NaN === false => false, isn\'t NaN falsy?
  2. Why NaN === NaN => false, but !!NaN === !!NaN => true

I\'v

7条回答
  •  有刺的猬
    2020-12-13 19:31

    This comparison also returns false:

    const x = NaN
    const y = x
    
    console.log(x === y) // false
    

提交回复
热议问题