How are javascript variables "hoisted" in these examples from MDN
<p>In <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Values,_variables,_and_literals#Variable_scope" rel="nofollow">this</a> mozilla article, I read:</p>

<blockquote>
  <p>Another unusual thing about variables in JavaScript is that you can refer to a variable declared later, without getting an exception. This concept is known as hoisting; variables in JavaScript are in a sense "hoisted" or lifted to the top of the function or statement. However, variables that aren't initialized yet will return a value of undefined.</p>
</blockquote>

<p>And then some examples:</p>

<pre><code>/**
 * Example 1
 */
console.log(x === undefined); // logs "true"
var x = 3;


/**
 * Example 2
 */
// will return a value of undefined
var myvar = "my value";

(function() {
  console.log(myvar); // undefined
  var myvar = "local value";
})();
</code></pre>

<blockquote>
  <p>Example 2, above, will be interpreted the same as:</p>
</blockquote>

<pre><code>var myvar = "my value";

(function() {
  var myvar;
  console.log(myvar); // undefined
  myvar = "local value";
})();
</code></pre>

<p>I fail to see anything being "hoisted"—at least not in the sense that I traditionally interpret the definition of the word: it seems like variables are <code>undefined</code> until after they are declared. In what sense can you "refer to a variable declared later"?</p>
