Immediate functions JavaScript
问题 Stoyan Stefanov says in JavasScript Patterns that: "you need an immediated function to wrap all your code in its local scope and not to leak any variables to the global scope" page 70. Here is his example (function() { var days = ['Sun','Mon']; // ... // ... alert(msg); }()); But surely because days is defined as a var, it will just be functional scope? The only benefit of the immediate function is the function is invoked immediately. There is no scope advantage. Corrcet? 回答1: It's not about