Possible Duplicate:
What do parentheses surrounding a JavaScript object/function/class declaration mean?
I simply don’t understand the usage of…
(function () {
//code
})()
…thing.
I call that a ‘thing’ couse’ I dont even know its name…
Is this a shorthand for onReady or onLoad event or it is for some kind of scope or closure thing?
If can anyone explain the usage and purpose of this syntax would be appreciated.
It’s known as a self executing function – It calls itself after its declarations.
Commonly used not to pollute the global namespace.
For a short but interesting article have a read here:
How Self Executing Functions Work