title: Why does console.log outside "for" loop print out an "extra" number?
body: <p>I'm working on some simple Javascript codes and there is something I'm not sure I understand. When I input this code,</p>
  
  <pre><code>for (var x = 0; x &lt; 5; x++)
  {
      console.log(x);
  }
  </code></pre>
  
  <p>naturally, it prints out 0 to 4. But if I add</p>
  
  <pre><code>for (var x = 0; x &lt; 5; x++)
  {
      console.log(x);
  }
  console.log(x);
  </code></pre>
  
  <p>then it will print out 0 to 5. Why does it print out 5?</p>