I'm watching an Angular JS tutorial that keeps using variations of this code snippet without explaining it.
(function(param, undefined){
//Normal function definition in here
...
}(bar.foo = bar.foo || {}));
So I get most if this. I recognize the following a self-executing function used to encapsulate bits of javascript to avoid scope pollution.
(function(param, undefined){
//Normal function definition in here
...
});
But I don't understand the syntax of having parentheses after a function definition.
Edit
I understand what is going on inside the parentheses.
What I don't understand is the syntax of having parentheses after a function definition: function(...){...}(...);