I have small doubt in the below code
for(var i=1; i<6; i++) {
console.log('Outside: ',i);
setTimeout(function(){ console.log('Inside: ',i); }, 1000);
}
Result of above code: is
Outside: 1
Outside: 2
Outside: 3
Outside: 4
Outside: 5
Inside: 6
Inside: 6
Inside: 6
Inside: 6
Inside: 6
Can any one explain?