...

View Full Version : Validation of an undeclared variable



colpaarm
08-23-2002, 09: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.

adios
08-23-2002, 09:45 PM
http://www.codingforums.com/showthread.php?threadid=1373&highlight=variable+exists

colpaarm
08-23-2002, 10:24 PM
Thanks big time. That did the trick.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum