[Javascript] checking to see if a variable exists

Peter Brunone peter at brunone.com
Wed Mar 3 13:41:03 CST 2004


	Okay, so I didn't mention that caveat.  Bad post.

	Nice to know I can always count on Tifer for info with a side of
sarcasm...

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of Chris Tifer

Hmmmm, what would happen in this instance?

var myVariable = false
if(myVariable){
    // Variable was initialized (exists), but it shouldn't get in here,
should it? }

Curious...

----- Original Message ----- 
From: "Peter Brunone" <peter at brunone.com>
>
> if(variable) {
> Do this with variable
> }
>
> -----Original Message-----
> From: javascript-bounces at LaTech.edu 
> [mailto:javascript-bounces at LaTech.edu] On Behalf Of Chris Basken
>
> Am I losing it?  Is there a way to see if a variable exists or has 
> been declared or something?
>
> You know, something like:
>
> if (isDeclared(foo)) {...
>
> or
>
> if (foo.isDeclared()) {...
>
> or something like that?





More information about the Javascript mailing list