I wanted to check whether the variable is defined or not. For example, the following throws a not-defined error
alert( x );
How can I cat
Technically, the proper solution is (I believe):
typeof x === "undefined"
You can sometimes get lazy and use
x == null
but that allows both an undefined variable x, and a variable x containing null, to return true.