The global object and local variables

JavaScript’s global object is the container of all global variables. Any top-level variable of any compilation unit will be stored in the global object. The global object is one of the worst parts of JavaScript when it is not used correctly, as it can easily become bloated with unneeded variables and can be unknowingly abused by developers when JavaScript default behavior is heavily relied upon. Here are two examples of such misuse:

To use the global object efficiently, you should wrap all your variables in a single application object, apply functions to it as needed, enforce type verification within the functions that you are applying to the application object in order to make sure that it is instantiated correctly and access the global object by thinking of it as a sort of immutable object with a few side-effect functions that are the application objects.