<code>undefined</code> instead of the value.
That is because of a feature of JavaScript called <em>hoisting</em>.
Any variable declaration is moved by the programming language to the top of the scope it belongs to.
As we saw at the beginning, <code>var</code> is scoped to the function,
so the previous example is the same as:</p>
<pre class="language-javascript line-numbers"><code class="javascript language-javascript"><span class="token keyword">var</span> name<span class="token punctuation">;</span>
consol