JavaScript: Check for undefined, null and blank values

2018-02-21 ·

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.

Copyright © 2018 All rights reserved.
Powered by Kulfon.