I'm launching a course about Next.js + React.jsLearn more

JavaScript: Check for undefined, null and blank values

2018-02-21 · 1 min read

In JavaScript:

if (value) {

will evaluate to true if and only if value is NOT:

  • undefined
  • null
  • NaN (Not a Number)
  • "" (empty string)
  • 0
  • false

All those values are considered falsy and return false with the if statement.

My Tech Newsletter

Get emails from me about programming & web development. I usually send it once a month