javascript - Why is the answer to this 10? -


this question has answer here:

i know outcome of 10:

var es = []; (var = 0; < 10; i++) {   es[i] = function () {     console.log(i);   }; } es[6](); 

any number of es[0] - es[9] still 10. why?

because after loop i 10. function prints reference of i.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -