January 2020
Intermediate to advanced
548 pages
13h 36m
English
As we've seen, typeof null evaluates to "object". This is an odd legacy of the language. Unfortunately, it means that we cannot rely on typeof for the detection of null. Instead, we must compare to the literal null value directly using a strict quality operator, as shown here:
if (someValue === null) { // someValue is null...}
Unlike undefined, null cannot be overwritten in any version of the language, nor in any environment, and so it doesn't come with any headaches around its usage.
Read now
Unlock full access