I've read "JavaScript. The Core by Dmitry Soshnikov" and i don't understand very well this code (refactoring). Why k is increment ?
var data = [];
for (var k = 0; k < 3; k++) {
data[k] = (function () {
console.log(k);
})(k)
}
data[0];
data[1];
data[2];
this portion of code :
(function () {
console.log(k);
})(k)
So when we add a parameter (k) to the end of a function, if i understand well, the value (k) is take from the current context/scope ?