Variable scope in Javascript for loop
<p>What's the difference between:</p>

<pre><code>function bar()
{
  for (x=0; x&lt; 100; x++) {}
}
</code></pre>

<p>And</p>

<pre><code>function bar()
{
  var x;
  for (x=0; x&lt; 100; x++) {}
}
</code></pre>

<p>If x wasn't declared outside of that function, and so it wasn't a global variable? I always wonder this because I generally don't declare throwaway variables which are used only in a loop, but I wonder if this might break comparability in a browser or such. </p>
