Blockless Scope: JavaScript Shenanigans
As a JavaScript developer, you've likely been told that let and const are block scoped. But, how does that work when there is no block? It doesn't get much more straightforward than this. // logs 10 ten times for (var i = 0;i < 10;i += 1) { setTimeout(() => console.log(i), 10); } // logs 0-9 for (let i = 0;i < 10;i += 1) { setTimeout(() => console.log(i), 10); } This classic example (which I talked about in Simplify setTimeout) shows a clear example of a variable and a block scope. But for
