I am working on some code in which this page has many .js files associated with it (using them as libraries). Each .js file looks like this:
(function() { .... all the lib functions and objects .... })();
After some playback, I see that the format functions (function () {...}) (); obtained automatically. If I separate the outer finger from the function () {...} , then the code is invalid. If I add a function name, then the code will be valid, but will not be executed until the function foo () {...} is called.
Is there a special reason why lib was written this way? I would suggest that it will encapsulate variable names, etc. What is the syntax of this that allows it to run automatically when the page loads?
source share