CodeAs follows:
(Function(){"Use strict ";//Declares strict mode....})();
Anonymous function reason:
Javascript has two scopes: global and local. If a variable is declared outside the definition of any function, the variable is a global variable andProgramYou can access and modify the value of this variable. If a variable is declared in a function definition, the variable is a local variable. NO content except this function can access this variable.
Code wrapped in anonymous functions can make the code private. Packaging code in anonymous functions is a good coding practice, because this can limit the scope of the code and avoid damage to the global namespace. In this way, you can avoid name conflicts or accidentally modify a value.
Although JavaScript does not support private members, you can use anonymous functions to create private members when using JavaScript encoding.
The extra parentheses at the end of the function declaration are used to call anonymous functions.
Strict mode:
Strict mode can provide better error checking for JavaScript code. When the strict mode is used, the code is more restrictive than that allowed by JavaScript normally.
For more limits, see: http://msdn.microsoft.com/zh-cn/library/windows/apps/br230269.aspx