[Javascript] checking to see if a variable exists

Chris Basken chriz at basken.com
Wed Mar 3 13:26:39 CST 2004


That gives me an error.

I just looked up:

"variableName" in window

As in:

alert("variableName" in window);

If "variableName" has been declared, it alerts true, otherwise it alerts
false.

So I guess I'm losing it.  Thanks tho.  :)

----- Original Message ----- 
From: "Peter Brunone" <peter at brunone.com>
To: "'[JavaScript List]'" <javascript at LaTech.edu>
Sent: Wednesday, March 03, 2004 2:13 PM
Subject: RE: [Javascript] checking to see if a variable exists


>
> 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?
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>






More information about the Javascript mailing list