I saw some sample code like this in Javascript. Is this AJAX?
(function() {
/*some code*/
})();
Thanks a lot!
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.
No. It’s what’s commonly referred to as an “immediately invoked function expression”, or IIFE.
The wrapping pair of parentheses cause the construct to be an expression, rather than a declaration. That’s necessary because you can’t have an anonymous function declaration (you’d get a syntax error).
They are commonly used to introduce a new scope (producing what you may have heard referred to as a closure).