title: If statement and variable hoisting
body: <p>I am learning about variable hoisting in JavaScript, and found this behavior weird:</p>
  
  <pre><code>var x = 0;
  
  (function () {
      //Variable declaration from the if statement is hoisted:
      //var x; //undefined
  
      console.log(x); //undefined
  
      if (x === undefined) {
          var x = 1; //This statement jumps to the top of the function in form of a variable declaration, and makes the condition become true.
      }
  }());
  </code></pre>
  
  <p>Is it correct, that in this case, the statement makes the condition true so it can be executed?</p>