JavaScript Global Imports


Problems with standard global use in module pattern:

  1. Entire scope chain is checked for non-local variables.
  2. Unclear scope leading to code that is tough to manage.


Use global imports by passing in global as a parameter of immediately invoked function. The value is closed up as local variable and can now be modified without worrying about changing the global.