This isn't a specific problem, but a more theoretical question. Is there ever a good reason to expose multiple global variables for a single Javascript application?
I can see using, and often use myself, a single global variable to name an object or class containing the app so that it can be recalled multiple times (example below), but I can't think of any case when any additional global variables couldn't be replaced by object properties.
Example where an exposed variable makes life easier (using a closure, it couldn't be recalled):
var myGlobalApp = {
init: function (args) {...},
methodOne: function () {...},
methodTwo: function () {...},
propertyOne: 'string for example'
};
myGlobalApp.init(arg1);
myGlobalApp.init(arg2);
Does anyone know of an instance case where multiple global variables would be necessary?
myGlobalAppAPP.domObjects.tables.dataTables.getFirst()a bit unwieldy? How big is your application and how much are you exposing the global namespace? I'd prefer to break it out into a few objects over one mammoth object. Your call.