All falsey values in JavaScript

前端 未结 4 1793
囚心锁ツ
囚心锁ツ 2020-11-21 07:21

What are the values in JavaScript that are \'falsey\', meaning that they evaluate as false in expressions like if(value), value ?

4条回答
  •  别跟我提以往
    2020-11-21 08:10

    Addition to the topic, as of ES2020 we have a new value which is falsy, it's BigInt zero (0n):

    0n == false // true
    -0n == false // true
    

    So with this, we now have 7 "falsy" values in total (not including document.all as mentioned by user above since it's part of DOM and not JS).

提交回复
热议问题