JavaScript and leaking global variables
<p>In JavaScript, if you do:</p>

<pre><code>var myvar = 5;
</code></pre>

<p>Then it will be local to that file, however if you accidentally forget <code>var</code> and just do:</p>

<pre><code>myvar = 5;
</code></pre>

<p>Then it becomes global.</p>

<p>Is there any good solution to fixing this, it seems to me that the default should have been that it is local, and you should do something like <code>global myvar = 5</code> in order to get a global.</p>

<p>There is <code>"use strict";</code> that I discovered to warn you but I was hoping for a more elegant solution and thought it must exist?</p>
