5.10 Equality Checks

Use identity operators (===/!==) except in the cases documented below.

5.10.1 Exceptions Where Coercion is Desirable

Catching both null and undefined values:

  1. if (someObjectOrPrimitive == null) {
  2. // Checking for null catches both null and undefined for objects and
  3. // primitives, but does not catch other falsy values like 0 or the empty
  4. // string.
  5. }