title: Hoisting order with IIFE involved, specific example
body: <p>I came across this code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var myVar = 'foo';
  
  (function() {
    console.log('Original value was: ' + myVar);
    var myVar = 'bar';
    console.log('New value is: ' + myVar);
  })();</code></pre>
  </div>
  </div>
  </p>
  
  <p>Questions:</p>
  
  <ol>
  <li>Is IIFE hoisted to the top before global <code>myVar</code>?
  1a. IF it is, is it executed before global <code>myVar</code> is declared?</li>
  <li>In IIFE I get <code>undefined</code> first, and <code>bar</code> second. What is the behind the scenes order of execution in IIFE?</li>
  </ol>