For example, imagine a for loop which instantiates a new local variable c in each iteration. Now, imagine that you increase the value of that variable c by 1 in each iteration. If you would like to print c to output console, 500ms after each increment, you would probably expect all iterations to have different values, right? However, what will happen is that all the print outs will contain the very same value.
In order to get a true block level variable in JS, we should enclose the iteration code in an anonymous function. This way, each anonymous function comes with its own scope, and closures (and setTimeout construct is a closure), will print correct (different) values.
Here is the example: