View Single Post
Old 12-08-2005, 03:02 AM  
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Javascript: How do I check if a var is null or hasn't been set??

sounds simple doesn't it? this is fucking driving crazy

lets say "myvar" was never mentioned in the code anywhere.
the following gives an error message "myvar is undefined" which I want to avoid:

Code:
if ( myvar = =  undefined )
{
   // do nothing
}
I also tried:
Code:
if ( myvar = =  null )
if ( myvar = =   0 )
if ( myvar = =   "" )
if ( myvar = =   '' )
of course I don't use spaces between the two "=" but that's just for displaying
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote