Your code sample
(function(){ ... })();
can be rewritten as
anonymous = function () { ... };
(anonymous)();
or, avoiding the redundant first brace pair, as
anonymous = function () { ... };
anonymous();
at the cost of introducing a name into the (here global) name space.
As pointed out by pst earlier, this construction is used to create a new scope. It is most useful in combination with closures, for example to implement the ubiquitous counter:
var counter = function (initval) {
var c = initval || 0;
return function () {
var r = c;
c += 1;
return r;
};
} (5);
counter () ; // 5
counter () ; // 6
counter () ; // 7