The purpose of “Self Invoking Anonymous Functions” [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What is the purpose of a self executing function in javascript? Hopefully quite a straight forward question: What is the purpose of using self invoking anonymous functions? Is it simply to prevent "polluting" the global scope with variables etc.? Or are there other advantages to using them? 回答1: Out of my personal experience, other than using anonymous functions for inducing a scope, I have also used it in for