title: Javascript: difference in execution of duplicate var and let variables within `execution context`?
body: <p>I have recently noticed below code works</p>
  
  <pre><code>var x = 10;
  var x = 20;
  </code></pre>
  
  <p>on the other side below throws error for redeclaration of same variable</p>
  
  <pre><code>let x = 10;
  let x = 20;
  </code></pre>
  
  <p>Below link gives insights by keeping <code>functional scope</code> vs <code>block scope</code> as reference.</p>
  
  <p><a href="https://stackoverflow.com/questions/49148068/why-does-var-allow-duplicate-declaration-but-why-does-const-and-let-not-allow-du">Why does var allow duplicate declaration but why does const and let not allow duplicate declaration?</a></p>
  
  <p><code>var</code> declarations are executed in <code>execution context</code>, a entry in variableObject is created and re-declarations points to same entry/variable again and again in case of duplication.</p>
  
  <p>How is this different in case of <code>let</code> ? </p>
  
  <p>Isn't it still executed in <code>execution context</code> ? </p>
  
  <p>Some good links or detailed explanation would be appreciated. </p>