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
Another potential "solution" is to use the window object. It avoids the reference error problem when in a browser.
window
if (window.x) { alert('x exists and is truthy'); } else { alert('x does not exist, or exists and is falsy'); }