[Javascript] checking to see if a variable exists

Chris Tifer christ at saeweb.com
Wed Mar 3 13:27:43 CST 2004


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>
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