Why the first argument inside IIFE i = 9, but not 10, is that mechanism how while operator work?
var i = 10;
var array = [];
while (i--) {
(function(i) {
console.log(i);
var i = i;
array.push(function() {
return i + i;
});
})(i);
}
// array[0]() => 18
If I use for operator, first argument in i = 10:
var i = 10;
var array = [];
for(;i>=0;i--) {
(function(i) {
console.log(i);
var i = i;
array.push(function() {
return i + i;
});
})(i);
}
array[0]() => 20