for (var iMago dint arr = []; I < = 3pi) {
arr.push(
(function(h){
return function(){
console.log(i);
}
})(i)
);
}
arr [0] (); / / 4
is also a question asked today, that is, are there any requirements for the parameters of anonymous functions? I used to understand that h is just a formal parameter and can be written as anything. But the result is not 0 as imagined, but 4. After changing h to I, the result is 0. What"s going on? shouldn"t that h be just a parameter