[jQuery] How do I check for the existence of an object?

2007-02-23 Thread Daemach
I want to create a global object to store some settings in, but only if it doesn't exist already. If it doesn't exist and I try to use something like if (myObj == 'undefined') myObj = new Object(); I get an error saying the object is not defined. Yeah I should know stuff like this ;) -- View

Re: [jQuery] How do I check for the existence of an object?

2007-02-23 Thread Klaus Hartl
Daemach schrieb: I want to create a global object to store some settings in, but only if it doesn't exist already. If it doesn't exist and I try to use something like if (myObj == 'undefined') myObj = new Object(); I get an error saying the object is not defined. Yeah I should know stuff

Re: [jQuery] How do I check for the existence of an object?

2007-02-23 Thread Mike Alsup
if (myObj == 'undefined') myObj = new Object(); I get an error saying the object is not defined. Try this instead: if (typeof myObj = 'undefined') myObj = {}; ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/

Re: [jQuery] How do I check for the existence of an object?

2007-02-23 Thread Blair Mitchelmore
You can do (typeof myObj == 'undefined') and I think you can also do (myObj == undefined) thanks to the completely mind-blowing line of code at the beginning of jQuery window.undefined = window.undefined; -blair Daemach wrote: I want to create a global object to store some settings in,

Re: [jQuery] How do I check for the existence of an object?

2007-02-23 Thread Daemach
Thanks all! Daemach wrote: I want to create a global object to store some settings in, but only if it doesn't exist already. If it doesn't exist and I try to use something like if (myObj == 'undefined') myObj = new Object(); I get an error saying the object is not defined. Yeah I