Truthy and Falsey values

Any value in Javascript can be considered a boolean if necessary.

Example:

if (2) {
  console.log("Is 2 Truthy?")
}

The most obvious place is in if conditions.

Everything in Javascript is truthy except:

  • false
  • 0 (the number 0)
  • "" (empty string)
  • null
  • undefined
  • NaN (not a number)
  • -0
  • 0n