function btFun(){
var arr = [];
for (var i =0; i<3; i++){
let j = i;
arr.push(
function(){
console.log(j);
}
)
}
return arr;
}
I have question that involves let
. When I execute the functions created with this code, I get
0
, 1
, 2
. And does that mean that let
did create a copy value of that i
iterator somewhere in memory and for each function it created reference to them?