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
An even easier and more shorthand version would be:
if (!x) { //Undefined }
OR
if (typeof x !== "undefined") { //Do something since x is defined. }