What's the purpose of lonely code blocks in Javascript?
<p>In Javascript, you can have lonely code blocks, that is, code blocks without an <code>if</code>, <code>function</code> or something like that preceding them, placed arbitrarily in the code, like this:</p>

<pre><code>var a = 3,
b = 4;
{
  a = 50;
  b = 50;
}
alert(a + b); //alerts 100
</code></pre>

<p>I know some other languages have this (I think C++ does), and they use it for scope control: variables declared inside the lonely code block cannot be accessed outside of it. But since Javascript has function scope rather than block scope, you have to use a self-executing function <code>(function(){})()</code> to acheive the same effect.</p>

<p>Is there a purpose for this construct? Have you ever seen anybody use it? Does the spec mention it? Is this just a side effect of the grammar having some sort of general rule about code blocks?</p>
