[Javascript] checking to see if a variable exists

Chris Tifer christ at saeweb.com
Wed Mar 3 13:49:40 CST 2004


I try :)

But I didn't use sarcasm there. I didn't test it out and was curious really.
I'm too lazy to test things most of the time.

I know where you were going with that - object detection. Like checking
(document.images) would return true if images was a collection (able to
perform rollovers, let's say).

That's why I thought it might work, but in my scenario, I figured it would
come out to false though.

Chris Tifer



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


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




More information about the Javascript mailing list