Possible Duplicate:
JavaScript scope and closure
What is this for?
(function(){
//The code to be executed
})();
Also, has this anything to do with closures?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’ve seen it often recently. I’m guessing:
No need to name the function. It implies it’s not reusable.
This gives you a local scope to declare variables using
var(otherwise, you would add them to global).