 <p>Hoisting moves function declarations and variable declarations to the top, but doesn't move assignments.</p> <p>Therefore, you first code becomes</p> <pre><code>var a; function f() { console.log(a.v); } f(); a = {v: 10}; </code></pre> <p>So when <code>f</code> is called, <code>a</code> is still <code>undefined</code>.</p> <p>However, the second code becomes</p> <pre><code>var a, f; a = {v: 10}; f = function() { console.log(a.v); }; f(); </code></pre> <p>So when <code>f</code> is called, <code>a</code> has been assigned.</p>