Generally, when you run into this pattern in JavaScript, it's someone attempting to make use of the module pattern. The pattern is generally considered a good way to protect your own code from interacting poorly with other libraries you may be using on your page (if you're coding in a web page).
See:
http://yuiblog.com/blog/2007/06/12/module-pattern/
Note, the wrapping parentheses at the beginning and end of the anonymous function declaration in the example code are not actually necessary. Paul Irish, in the video linked below, believes these are often included as a heads up to anyone reading the code that the code is meant to be self-contained, and not just procedural code.
By this I mean:
function(){
//Stuff goes here....
}();
Is just as valid as:
(function(){
//Stuff goes here....
}());
And:
(function(){
//Stuff goes here....
})();
And:
!function(){
//Stuff goes here....
}();
Et cetera.
Paul Irish talks about this pattern in this video:
http://paulirish.com/2010/10-things-i-learned-from-the-jquery-source/