Title I have stolen from here.

Here is my example. This example will return five times five:

for (var i=0; i < 5; i++) {
	setTimeout(function () {
    console.log(i)
  }, i*1000)
}

And this example will return 0, 1, 2, 3, 4:

var aa = function (a) {setTimeout(function () {
    console.log(a)
  }, i*1000)};
  
for (var i=0; i < 5; i++) {
	aa(i);
}