;! function () {} (); ;! What's the use?
From the syntax, the semicolon in JavaScript indicates the end of the statement, and at the beginning, it may be used for compression and other methods to split, indicating a new statement begins. So, if in a separate JS file, the beginning of the semicolon is meaningless, can be deleted.
An exclamation point is a logical operator, a "non", a common use of the IF (!true) {}, whereas the operator is preceded by the function definition as a whole, then the function is called, and the returned structure is logically calculated.
Plainly, here is the building of an immediate execution function, it is recommended that the landlord know the meaning can be, when they write, you can use a clearer format:
(function () {}) ();
Add a point here: Add "()" after the function Declaration "functions () {}", meaning that the function declaration is executed. Some are called "anonymous auto-execute functions" and more accurately represent "execute functions immediately".
But execute the function immediately, as part of the expression, or the JS interpreter will report a syntax error. In general, the easiest way to understand an expression is to add a parenthesis to the left and right ends, such as "(function () {})". Therefore, the most common notation for executing functions immediately is "(function () {})", which is a statement that can be added "before and after"; 】。
In fact, the immediate execution of the function is also a n-type, such as "(function () {})" is also OK, before the function declaration with a unary operator also line: "!function () {} ()", "~function () {} ()". Even a combination of unary operators can: "!!!! function () {} () "," ~~~function () {} () ","!~!function () {} () ").
JS pre-plus semicolon and exclamation point meaning