Prevent 'global' references in javascript
<p>I've got a problem of having code variable names conflicting each other, ie;</p>

<pre><code>&lt;script type="text/javascript"&gt;var a = "hello"; &lt;/script&gt;
&lt;script type="text/javascript"&gt;alert(a);//this works, when I want 'a' not to exist &lt;/script&gt;
</code></pre>

<p>Are closures the only option? </p>

<p>Coming from a c# background, its like constructing an unreferenced instance of a delegate, then calling it inline, which seems a bit messy</p>

<pre><code>(function(){var a = "hello";})();
(function(){alert(a);})();//yes! working as expected
</code></pre>
