javascript - Why does underscore use immediately invoked function expression to wrap all of its code? -


<html>     <head>      </head>     <body>         <script src="underscore.js"></script>         <script src="app.js"></script>     </body> </html> 

i saw whenever html loaded, code in underscore.js (even code don't need) executed because of invoked function expression. flaw of underscore.js? why don't wrap code of underscore.js inside normal object instead of function object (the invoked function expression) ?

it common pattern can control export. .call(this) may put on window or node's global.

as "all code ... executed" - functions won't executed, parsed other scripts.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -