The example below was taken from a StackOverflow answer which helps to identify a closure.
for (var i = 0; i < 10; i++) {
(function f() {
var i2 = i;
setTimeout(function g() {
console.log(i2);
}, 1000);
})();
}
The following explanation was given:
For g:
List the variables: console is a free variable. i2 is a free variable. Find the parent scope to which each free variable is bound: console is bound to the global scope. i2 is bound to the scope of f. In which scope is the function referenced? The scope of setTimeout. Hence console is not closed over by g. Hence i2 is closed over by g.
However I am not able to understand the bolded part - could you explain it to me?