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

前端 未结 7 854
走了就别回头了
走了就别回头了 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:20

    NaN and false are both the subset of Falsy.

    • NaN == false -> they're both falsy -> thus 'TRUE'
    • NaN === false -> they're NOT the same type -> thus 'FALSE'

提交回复
热议问题