What is the output of the following code?
i is declared using let:
let arr = []; for (let i=0; i < 3; i++) { arr.push(function () { return i }); } let value = arr[0](); console.log(value); /
0
When we use let in a for-loop, each iteration of the loop will get its own i variable and any closures created close over their own value of i.