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.

Subscribe to My Newsletter

The latest programming-related news, articles and resources - sent to your inbox monthly. Unsubscribe anytime.