Principle
Functions contain functions, i.e. closures.
The result of the include function is that the child function will hijack the parent function's active object. When a child function accesses a variable, it first reads its own active object, whether it contains this variable, does not find it from the parent function, does not, go to the ancestral function, and layers back to the window, not returning to undefined.
Advantages
object, the basis of modularity.
Disadvantages
Additional memory overhead: the child function will hijack the parent function's active object before it is destroyed.
ie8-(IE8 and IE8) are prone to memory leaks: Ie8-'s DOM is written by COM, and standard browser (chrome,firefox,safari,opera) memory reclamation is reference cleanup, and ie8-is a token count. The difference between the two:
Tag count, once a circular reference (especially access to the DOM) is made, a memory leak is caused.
Closure optimization
When you are finished, assign null/undefined to the child function. Free up memory in a timely manner.
Example
jquery monolithic architecture with closures
(function(window, undefined) { ... attr:function() { } ...}) (window)