4 ms·
If Javascript didn't have closures, then var's scoping rules would largely be academic. But in practice, there are many cases when I have to create multiple ca
by tangent128 11y ago
If Javascript didn't have closures, then var's scoping rules would largely be academic.
But in practice, there are many cases when I have to create multiple callbacks in a loop; half the time I forget that, in Javascript, declaring a variable inside a loop does not actually create a variable local to the loop, and so have to keep debugging why all my callbacks are behaving exactly the same.
The let statement appears to adopt Lua-style lexical scoping, which will be a breath of fresh air once I can rely on browser support.