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 like this ;)
You have to use the typeof operator: if (typeof myObj == 'undefined') myObj = new Object(); But I would write that as follows anyway: var myObj = myObj || {}; -- Klaus _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/