for (var i = 1; i < 5; i++) {
console.log(i);
setTimeout(function() {
console.log(i);
}, 3000)
};
first, this code displays the numbers from 1 to 4, and after three seconds - four fives. this is not an obvious sequence of actions. I would suppose the output should be like this:
1 //pause 3s
1
2 //pause 3s
2
3 //pause 3s
3
4 //pause 3s
4
what I need to know about the JS-interpreter to give the correct answer? the question is not at all about closures