Re: Getting the object type
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Getting the object type

From: Michael Powe <michael+gnus@trollope.org>
Date: Sun Jan 29 2006 - 20:59:16 CET

>>>>> "Dominik" == Dominik Werder <13thmonkey@arcor.de> writes:

>> No, it does not give any warnings on my ff1.5 ff output:
    Dominik> [..]

    Dominik> Warning: reference to undefined property y.nodeName
    Dominik> Source File: dom1.html Line: 9

    Dominik> Warning: reference to undefined property y.nodeName
    Dominik> Source File: dom1.html Line: 9

Well, yes, of course you will get a warning for trying to reference an
undefined property. Why would you want it otherwise? You can use a
couple methods to get around this.

if (o.nodeName != null)
if (o.nodeName != undefined)
if (typeof o.nodeName != "undefined")

They should all get you to the same place.

In most languages with which I am familiar, referencing an undefined
variable or object will abort compilation or crash your program.

Thanks.

mp

-- 
Michael Powe		michael@trollope.org		Naugatuck CT USA
"After I asked him what he meant, he replied that freedom consisted of
the unimpeded right to get rich, to use his ability, no matter what the
cost to others, to win advancement." -- Norman Thomas
Received on Tue Feb 7 21:26:45 2006