I donβt think that itβs ever strictly necessary to have several globals - JavaScript objects can be arbitrarily nested and can often be used as namespaces.
window.AwesomeModule = { app: { ... }, util: { ... } };
In fact, if your application cannot be reused (that is, it is simply accessed by the user), you may not be able to skip any global variables.
(function() { var AwesomeModule = { ... };
A more interesting question is whether multiple global values ββwill really be useful, and I would say that it depends on your development style. For example, if we look at C # and .NET in general, we will see that the entire infrastructure (more or less), namespaces and everything, is located below the top System namespace.
Of course, if you are going to create a huge JavaScript application with several components, I would definitely not recommend such a nested structure (in addition to being cumbersome, JavaScript JavaScript attributes have a certain cost of execution, which can add up).
... Despite this, the JavaScript landscape is not trimmed so well. A simple check of global attributes gives about 56 elements on my machine on a blank page (Chrome works).
var i = 0; for (var prop in window) { if (window.hasOwnProperty(prop)) { i++; } }
So, although we can and should minimize our own global use, the JS environment that exists today (especially when using external libraries) is often associated with the distribution of global variables. Example: StackOverflow has about 144 common global bindings.