title: Why incrementor is printing 3 even condition is checking for less then 3?
body: <p>for below code output will print "3" for 3 times, i.e updates same variable for 3 times</p>
  
  <pre><code>for(var k=0;k&lt;3;k++){
   setTimeout(()=&gt;{
        console.log(k)
      },1000) 
  }
  </code></pre>
  
  <p>similarly if i use let instead of var 1,2,3</p>
  
  <pre><code>for(var k=0;k&lt;3;k++){
   setTimeout(()=&gt;{
        console.log(k)
      },1000) 
  }
  </code></pre>
  
  <p>i know why it prints 0,1,2 as i is different every time. i'm just wondering why its printing 3 in case of var as condition is to checking for less then 3?</p>