For the complete documentation index, see llms.txt. This page is also available as Markdown.

falsy

下面哪些值是 falsy?

0
new Number(0)
('')
(' ')
new Boolean(false)
undefined
  • A: 0, '', undefined

  • B: 0, new Number(0), '', new Boolean(false), undefined

  • C: 0, '', new Boolean(false), undefined

  • D: All of them are falsy

答案: A

只有 6 种 falsy 值:

  • undefined

  • null

  • NaN

  • 0

  • '' (empty string)

  • false

Function 构造函数, 比如 new Numbernew Boolean,是 truthy

最后更新于