title: Why is this variable 4？
body: <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>console.log(window.b,b) //undefined undefined
  if(true){
      console.log(b) //ƒ b(){} does it get hoisted?
      b = 4
      function b(){}
      b = 3
      console.log(b) //3  Why is this variable 3
  }
  console.log(window.b,b) //4 4   Why is this variable 4</code></pre>
  </div>
  </div>
  </p>
  <p>If the code removes this line</p>
  <pre><code>function b(){}
  </code></pre>
  <p>The browser will report an error <code>VM114:1 Uncaught ReferenceError: b is not defined</code> at line 1 <code>console.log(window.b,b) </code></p>
  <p>Can someone tell me why it works like this？？</p>
  <p>if <code>function b</code> gets hoisted, does it equals to</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>console.log(window.b,b) //undefined undefined why it doesn't cause an ReferenceError b is not defined
  if(true){
      function b(){}
      b = 4
      b = 3
      console.log(b) // 3
  }
  console.log(window.b,b)  // ƒ b(){} ƒ b(){}</code></pre>
  </div>
  </div>
  </p>
  <p>I am not a native English speaker,hope you can understand.</p>