colpaarm
08-23-2002, 08:39 PM
Hi guys. I have some client side javascript code that makes reference to a javascript variable. However, that variable may not always be there. How do I check to see if a variable has been declared? Realize that this is different than checking to see if a variable is defined. For example
var NewVar;
if ( NewVar == null)
//Execute something
This works just fine. However in my case, I'll have (in some cases)
if ( NewVar == null)
//Execute something
In this case, the variable has not even been declared. The if statement generates an error that basically says that the variable hasn't been declared. Some my question becomes, how do you check to see if a variable has been declared? Thanks in advance for your help.
var NewVar;
if ( NewVar == null)
//Execute something
This works just fine. However in my case, I'll have (in some cases)
if ( NewVar == null)
//Execute something
In this case, the variable has not even been declared. The if statement generates an error that basically says that the variable hasn't been declared. Some my question becomes, how do you check to see if a variable has been declared? Thanks in advance for your help.