title: Why does var allow duplicate declaration but why does const and let not allow duplicate declaration?
body: <h2>Why does var allow duplicate declaration but why does const and let not allow duplicate declaration?</h2>
  
  <p><code>var</code> is allow duplicate declaration </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>xx=1;
  xx=2;
  console.log(xx+xx);//4
  
  var xx=1;
  var xx=2;
  console.log(xx+xx);//4
  
   </code></pre>
  </div>
  </div>
  </p>
  
  <p>But <code>let</code> and <code>const</code> does not allow duplicate deceleration </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>const yy=1;
  const yy=2;
  console.log(yy+yy);//Uncaught SyntaxError: Identifier 'yy' has already been declared",
  
  let zz=1;
  let zz=2;
  console.log(zz+zz);//Uncaught SyntaxError: Identifier 'zz' has already been declared",</code></pre>
  </div>
  </div>
  </p>
  
  <p>I saw something about that in <a href="https://stackoverflow.com/questions/762011/whats-the-difference-between-using-let-and-var-to-declare-a-variable">here</a> like,</p>
  
  <blockquote>
    <p>Assuming strict mode, <code>var</code> will let you re-declare the same variable in the same scope. On the other hand, <code>let</code> will not.</p>
  </blockquote>
  
  <p>But I want to know Why <code>let</code> and <code>const</code> doesn't allow re-declaration? and why <code>var</code> does? and  How JavaScript handle these three type of deceleration ?</p>