03. Loops
// Using var
const arr = [];
for (var i = 0; i < 3; i++) {
arr.push(() => i);
}
arr.map(x => x()); // [3,3,3]
// Using let
for (let i = 0; i < 3; i++) {
arr.push(() => i);
}
arr.map(x => x()); // [0,1,2]Last updated
// Using var
const arr = [];
for (var i = 0; i < 3; i++) {
arr.push(() => i);
}
arr.map(x => x()); // [3,3,3]
// Using let
for (let i = 0; i < 3; i++) {
arr.push(() => i);
}
arr.map(x => x()); // [0,1,2]Last updated