A common practice is to create a global namespace reference in order to organize and share code while keeping a decent separation of concerns. ( Angular, React, jQuery etc. all do this. )
One of the first mainstream module systems for Javascript that includes asynchronous loading and a build system.
Uses the asynchronous module definition specification ( AMD ).
Has it's own module system like require, but doesn't have a lazy/async loading system. Also known as Direct Injection or DI.
Angular also defines different types of modules trying to add an opinionated design pattern to your application.
Another module standard.
The ES6 standard. Most flexible.
We see in the second example that the variable 'i' does not get hoisted and is not accessible to the rest of the function.
Ultimately does the job, but can become a nightmare to maintain and test.
A promise can be invoked and our code can respond once it is resolved or rejected.
A promise that never resolves will never finish code execution.
As long as we have a reference to the promise, different sections of our code can respond to the resolution.
WeakMaps have the following methods... set, get, delete and has.
Javascript is functionally scoped, so the reference keyword `this` changes with it's context. Fat arrow cleans this up a bit.
An interesting use of WeakMap, class, =>, and multi-line string interpolation with Angular Controllers...
babel.io
browserify
jspm.io
MDN
Resources
Code Example
http://code.livingsocial.net/iquattlebaum/mobile/tree/babel-demo