...

View Full Version : Another newbie Q: how to check for undef



mc1
08-26-2002, 10:36 AM
Hi,
I am new to javascript, having only just learned basic Perl and utilising the defined keyword, is there anything that I can utilise to check if an object is undefined or defined as in Perl?

Thanks
mc1

UPDATE_UPDATE_UPDATE_UPDATE_UPDATE_UPDATE

Thank you for the quick reply, it was just what I needed,
went for the ...

// code_start

if (typeof(error2) != "undefined") {
do something
}
// code_end

instead of the myriad of other solutions instead, thanks again

mc1

requestcode
08-26-2002, 01:08 PM
I would check this out:
http://www.codingforums.com/showthread.php?s=&threadid=1373

nolachrymose
08-26-2002, 01:09 PM
if(typeof myVariable != "undefined") { //variable exists
//statements...
}

Hope that helps!

Happy coding! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum