Hint
IIFEs create new scope β the pre-let solution to capture loop variable values.
for (var i = 0; i < 3; i++) {
(function(j) {
setTimeout(() => console.log(j), 0);
})(i);
}0 1 2
Explanation: The IIFE creates a new function scope for each iteration, capturing the current value of i as j. This was the pre-let fix for the classic closure bug.
Key Insight: IIFEs create new scope β the pre-let solution to capture loop variable values.