Possible Duplicates:
Javascript closure inside loops - simple practical example
Javascript closure “stores” value at the wrong time
for (var i = 1; i <= 3; ++i) {
setTimeout(function() {
alert(i);
}, i * 1000);
}
This alerts "4" 3 times. I know why, but I won't spoil it here... although I forgot how to fix it. What's a concise way of solving this problem?