Skip to content

Instantly share code, notes, and snippets.

@joe-oli
Created March 19, 2020 02:15
Show Gist options
  • Save joe-oli/b40ead6678c189f0a28ff1a72043eba7 to your computer and use it in GitHub Desktop.
Save joe-oli/b40ead6678c189f0a28ff1a72043eba7 to your computer and use it in GitHub Desktop.
Truthy vs Falsy in JS
From http://www.sitepoint.com/javascript-truthy-falsy/
The following values are always falsy:
* false
* 0 (zero)
* "" (empty string)
* null
* undefined
* NaN (a special Number value meaning Not-a-Number!)
All other values are truthy !! this includes:
"0" (zero in quotes),
"false" (false in quotes),
empty functions,
empty arrays,
and empty objects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment