JavaScript Global Imports

01.30.2015

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.

Solution:

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.