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