I've seen two ways of writing an Immediately-Invoked Function Expression:
// A - Parentheses around
// the function. Then
// invocation.
var a = (function() {
return 4 + 5;
})();
// B - Parentheses
// around the function
// AND the invocation.
var b = (function() {
return 4 + 5;
}());
console.log('a: %s - b: %s', a, b);
// Result: a: 9 - b: 9
From what I can say: Both ways work.
But I'm wondering:
What is the correct way?
Or are there different situations where I have to prefer the one way over the other?