Dan Schnau

Truthiness and Falsiness in JavaScript

JavaScript has ‘truthiness’ and ‘falsiness’.

Things that are “falsey”:

  • null
  • undefined
  • false
  • 0

Things that are “truthy”

  • function() {}
  • '' (empty string)
  • 'any other string'
  • true
  • 1 (or any number, apart from 0)
  • [] (empty array)
  • {} (new object)
  • Object