JS's understanding of (function (window, undefined) {}) (window) writing [network arrangement] (function (window, undefined) {}) (window); this, why should we pass window and undefined as parameters to it? (Function ($, undefined) {}) (jQuery); similarly, because ecmascript executes JS code from the inside out, it transmits the global variable window or jQuery object, this avoids searching for the outer layer and improves efficiency. Undefined is not supported in older browsers. If it is used directly, an error is reported. The js framework must consider compatibility. Therefore, an undefined parameter is added. Also, do not pass the window. undefined parameter to the form parameter. It is possible that the window. undefined has been modified by others. It is best to do nothing, and the undefined of the form parameter is actually undefined. Js Code: var undefined = 8; (function (window) {alert (window. undefined); // 8 alert (undefined); // 8}) (window); with Js Code: var undefined = 8; (function (window, undefined) {alert (window. undefined); // 8 alert (undefined); // The undefined parameter here is the local name of the undefined variable, and the value is undefined}) (window); Distinguish the above two methods: the first method is to find a window for each statement. The second method is to pass the window as a parameter. Yes, instead of finding the window for every statement, it should improve the efficiency. Therefore, even if undefined is defined by others, the undefined is still unaffected. It is probably to prevent the external variable definition from affecting the encapsulated interior to the greatest extent. For more information, see http://www.software8.co/wzjs/javascript/2525.htmljscode: // method 1 (function (undefined) {window. property1 = ......; Window. property2 = ......; ...... }) (); // Method 2 (function (window, undefined ){... // code goes here}) (window); // method 3 (function (undefined) {var tmp = window; tmp. property1 = ......; Tmp. property2 = ......; ...... }) (); Method 1 has the lowest efficiency, and method 2 should be similar to method 3. Pass window as a parameter so that the statements in the code can directly use the window in the parameter, instead of looking for the outermost object. If you want to set another 100000 properties for window in the function, you only need to find the outermost layer object once after passing the parameters. You do not need to pass parameters. All the statements that use window need to find the outermost layer object.