Why let and var bindings behave differently using setTimeout function? [duplicate]
With var you have a function scope, and only one shared binding for all of your loop iterations – i.e. the i in every setTimeout callback means the same variable that finally is equal to 6 after the loop iteration ends. With let you have a block scope and when used in the for loop … Read more