Skip to content

Instantly share code, notes, and snippets.

@amysimmons
Last active February 7, 2018 08:27
Show Gist options
  • Save amysimmons/eb8a31cdaea070880b07f691314b4e89 to your computer and use it in GitHub Desktop.
Save amysimmons/eb8a31cdaea070880b07f691314b4e89 to your computer and use it in GitHub Desktop.
// falsy values
Boolean(undefined) // false
Boolean(null) // false
Boolean(NaN) // false
Boolean(-0) // false
Boolean(+0) // false
Boolean("") // false

// everything else is truthy
Boolean(1) // true
Boolean(-1) // true
Boolean("a") // true
Boolean({}) // true
Boolean(() => {}) // true
Boolean([]) // true

// even object wrappers (created by the use of the word new) around falsy values are truthy 
Boolean(new Boolean(false)) // true
Boolean(new Boolean(0)) // true
Boolean(new Boolean("")) // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment