Possible Duplicate:
What is the purpose of a self executing function in javascript?
Explain JavaScript's encapsulated anonymous function syntax
for instance:
(function($) {
document.getElementById("foo").innerHTML = 'bar';
})();
I understand that we want to create our own scope to prevent variable collision but why does javascript need to have ()()?
That makes it a self-invoking anonymous function.