[thelist] does JavaScript have an equivalent to IsDefined()?

Sam Foster austin.pm at sam-i-am.com
Sat Dec 11 21:00:09 CST 2004

(this was languishing in my drafts folder from god knows when, but it 
might still prove useful to someone?)

Sarah wrote:
> More ASP/JavaScript woes :) Is there a JavaScript equivalent to the 
> ColdFusion IsDefined() function? I would like to be able to test to see 
> if a variable is defined in the querystring, but none of the methods I 
> have tried has worked. I have tried:
> if (Request.QueryString('id') == null) //...
> if (Request.QueryString('id') == undefined) //...
> if (Request.QueryString('id') == 'undefined') //...
> if (typeof Request.QueryString('id') == undefined) //...
> if (typeof Request.QueryString('id') == 'undefined') //...

You should check the value of
	typeof Request.QueryString('id');
if it's undefined, it should give you a string 'undefined'..


More information about the thelist mailing list