DEV Community

loading...

Discussion on: What's a closure?

Collapse
wulymammoth profile image
David

A popular interview question that I used to ask:

What happens here?

for (var i = 1; i <= 3; i++) {
  setTimeout(function() {
    console.log(i);
  }, 1000);
}