Js question from challenge
Hello SL, I have a problem with the following code: for(var i = 0; i <= 5; i++) { setTimeout(function(){ console.log(i) }, i * 1000); } This code Outputs 6 6 6 6 6 6 What I do understand is that setTimeout function is a closure, because it is the inner function that accesses the variable i of the outer for loop, creating a function object multiple times. But, what I dont know is what does the second parameter of the setTimeout function mean? i * 1000, I dont know what that does. Also, for the outcome, I suppose setTimeout only makes 6 function objects without executing them, and waits until i is greater than 5, which is 6, and than the for loop stops? The thing which i have the biggest problem with is this i * 1000 parameter. Thanks in advance.