Why would one write global code inside a function definition-call pair?
<p>I see examples where JavaScript code including jQuery and jslint use the notation below:</p>

<pre><code>(function(){
  // do something
})();
</code></pre>

<p>instead of:</p>

<pre><code>// do something
</code></pre>

<p>I first thought this is just for local scoping, i.e. creating local variables for the code block without polluting global namespace. But I've seen instances without any local variables at all too. </p>

<p>What am I missing here?</p>
