I am not asking if the variable is undefined or if it is null. I want to check if the variable exists or not. Is this possible?
null
What you're after is:
window.hasOwnProperty("varname");
A safer approach might even be:
this.hasOwnProperty("varname");
Depends on your calling context though...