3 ms·
I don't think that's limited to just `var`, as a `let` outside of the `for` will do the same let funcs = []; ;(() => { let i; for (i =
by mdaniel 3y ago
I don't think that's limited to just `var`, as a `let` outside of the `for` will do the same
let funcs = [];
;(() => {
let i;
for (i = 0; i < 10; i++) {
funcs.push(function() { console.log('i=',i); })
}
})()
for (let f of funcs) {
f.call(null);
}
(I used an IIFE to hide the "let i" from the .call to ensure it wasn't late binding to the name like the python example did)