DEV Community

Discussion on: Javascript true false weirdness

Collapse
 
eljayadobe profile image
Eljay-Adobe

The === equality check is a strong check. If something is truthy is does not necessarily equality-check to true.

Most everything in JavaScript is truthy. The 8 things that are falsy are:

  • false
  • 0
  • ""
  • null
  • undefined
  • -0 (I know, that's underhanded, but -0 is slightly different than 0)
  • NaN
  • document.all (in the HTML context)

Things that are truthy that occasionally mess people up:
var b = new Boolean(false)
var a = []
var o = {}

Collapse
 
nk2303 profile image
Ngan Kim Khong

Thank you for the concept! Wow. It's really concise and simple, yet can give me great bugs if not careful :)