title: how to interpret the result ( understand let and var in js)
body: <p>consider the following code</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>var fs = [];
  
  for(var i=0;i&lt;10;i++){
   fs.push(i =&gt; console.log(i));
  }
  
  fs.forEach( f =&gt; f());</code></pre>
  </div>
  </div>
  </p>
  
  <p>If the function is changed to:</p>
  
  <pre><code>for(let i=0;i&lt;10;i++){
      fs.push(function(){
          console.log(i)
      });
  }
  </code></pre>
  
  <p>It will print the 1,2,3,4,5,6,7,8,9 expected output.</p>
  
  <p>I am not understanding why. Can someone help.</p>