JavaScript: undefined !== undefined?

The problem is that undefined compared to null using == gives true.
The common check for undefined is therefore done like this:

typeof x == "undefined"

this ensures the type of the variable is really undefined.

Leave a Comment