setTimeout to print consecutive numbers: Closure
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5226285/settimeout-in-a-for-loop-and-pass-i-as-value">setTimeout in a for-loop and pass i as value</a>  </p>
</blockquote>



<pre><code>for(i=0;i&lt;5;i++){  
 setTimeout(
 function(i){
   console.log(this.i)
 },1000);
}
</code></pre>

<p>This is printing 5 for 5 times. How to make this print 0,1,2,3,4?</p>
