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:
if (someObjectOrPrimitive == null) {
// Checking for null catches both null and undefined for objects and
// primitives, but does not catch other falsy values like 0 or the empty
// string.
}