Possible Duplicate:
What is the purpose of a self executing function in javascript?
What does this mean? (function (x,y)){…}){a,b); in JavaScript
I see sometimes functions defined like these examples :
(function() {
....
})();
(function(param) {
....
})(JQuery);
(function(chat, Friend) {
....
})(chat, chat.module("friend");
After some web researches, I didn’t find any information about the meaning of the last parentheses information.
Is there someone to explain how to use it? Or simply point a web link explaining the meaning?
The
()in the end causes the code inside the function to be executed immediately.The
(JQuery)in the end causes the code inside the function to be executed immediately, passingJQueryas a parameter to it.The
(chat, chat.module("friend"))in the end causes the code inside the function to be executed immediately, passingchatandchat.module("friend")as parameters to it.