_.isNil

❗️Lodash onlyChecks if value is null or undefined.

  1. // Lodash
  2. console.log(_.isNil(null))
  3. // output: true
  4. console.log(_.isNil(NaN))
  5. // output: false
  6. console.log(_.isNil(undefined))
  7. // output: true
  8.  
  9. // Native
  10. console.log(null == null);
  11. // output: true
  12. console.log(NaN == null);
  13. // output: false
  14. console.log(undefined == null)
  15. // output: true

Browser Support

ChromeEdgeFirefoxIEOperaSafari