JavaScriptComparison Operations

Remarks

When using boolean coercion, the following values are considered "falsy":

  • false
  • 0
  • "" (empty string)
  • null
  • undefined
  • NaN (not a number, e.g. 0/0)
  • document.all¹ (browser context)

Everything else is considered "truthy".

¹ willful violation of the ECMAScript specification

Related Examples