Possible Duplicate:
What does this mean? (function (x,y)){…}){a,b); in JavaScript
Please anyone explain and give example about the Javascript below, I can’t find any document that explain about this:
(function([arg, arg ...]) {
//javascript code here
})([str, str ...]);
I’m asking this question because I see in the Google also Facebook javascript code, most of the them using this syntax.
What’s happening is, an anonymous function expression is defined (in parentheses) –
The function is then immediately called using the
()at the end of the function, just as as you’d call a normal functionvar result = someFunction(). So , for example –You can also pass arguments to the anoymous function, via the parentheses –