I. The closure concept in JS
Code Model: (function () {*******//inside is the code that writes the specific function *******}) ();
The effect of parentheses:
A. The first is to represent the role of code segmentation;
B. The second is to represent an operator that indicates the function it is going to run (for example, the last parenthesis in the upper line of code indicates the meaning of the run);
Second, how to create your own JS Library
The Code template is: (function () {
function $ () {
Code
}
window[' IC ']={}; Window[' namespace ']={} namespace
windwo[' IC ' [' $ ']=$;
})();
Three, JS FAQ
1. JS is case-sensitive;
2. js in single quotation marks, the difference between double quotation marks (single quotation marks can have double quotes, double quotation marks can have single quotation marks, single quotation marks in the use of the escape character "\");
3. The effect of parentheses is two, one is the function of the segmentation code, the other is the operator, the function of executing functions;
4. The difference between a function invocation and a reference;
var too = example (); Assign the example function return value to the too variable.
var too = example; Assign a example function pointer (a reference to a function);
5. Line break, "\", does not appear in the browser, the role of newline. The other is to connect with the "+" number connector;
6. Optional rules for semicolons and curly braces; (after each line ends with a semicolon);
7. Overloading, JS is not support overloading, when two the same function is, only load the last function of the code content to overwrite the previous function;
8. The problem of scope and closure in JS; (Closure: is a scope-related concept that refers to an intrinsic function that can still access the properties of its external function even after execution of the external function has completed and terminated)
JS of the relevant knowledge content