title: Difference between let and var in JavaScript
body: <p>I was going through the javascript style guide by Airbnb (<a href="https://github.com/airbnb/javascript" rel="noreferrer">https://github.com/airbnb/javascript</a>). </p>
  
  <p>In section 2.2 it is explained that</p>
  
  <p>let is block-scoped rather than function-scoped like var.</p>
  
  <pre><code>// bad
  var count = 1;
  if (true) {
    count += 1;
  }
  
  // good, use the let.
  let count = 1;
  if (true) {
    count += 1;
  }
  </code></pre>
  
  <p>I didn't get why the first one is bad practise and second is bad and if both let and var are block scoped then what difference does it make, if I use either of them?</p>
  
  <p>Also what is the difference between function scoped and block scoped?</p>