title: Hoisting and 'let' in JavaScript
body: <p>Question is: </p>
  
  <p>why doesn't this throw a reference error: </p>
  
  <pre><code>console.log(a)
  let a = 5;
  </code></pre>
  
  <p>but this throws a reference error: </p>
  
  <pre><code>{
   console.log(a)
   let a = 5;
  }
  </code></pre>
  
  <p>Now, if we use 'var' then in both cases the code will run and log out 'undefined', but can someone explain what's happening with 'let' (and 'const').</p>