JavaScript variable scoping not expecting result
<p>Whats happening to <code>bar</code> on the second console.log? Shouldn't it be "Andy" or throw a Reference Error? Also, why is <code>foo</code> not undefined? </p>

<p>Using Chrome.</p>

<pre><code>// lexical scope example
var bar = "Andy";
try {
    console.log(bar); // Andy
    (function() {
        console.log(bar); // undefined!
        var bar = "B",
            foo = "Last Name";
        console.log(bar); // B
        console.log(foo); // Last Name
    })();
    console.log(bar); // B
    console.log(foo); // Reference Error
} catch (e) {
    console.log(e);
}​
</code></pre>

<p>JSFiddle of the above:
<a href="http://jsfiddle.net/2D9fj/3/" rel="nofollow">http://jsfiddle.net/2D9fj/3/</a></p>
