Why does the following code produce a different result in StackBlitz vs Chrome Dev Tools?
I would expect i
to be undefined
outside the for
loop (agreeing with the Chrome Dev Tools result).
What is going on here with the Stackblitz result?
Stackblitz (blank ES6 project)
Chrome Dev Tools
StackBlitz transpiles code to ES5, thus changing let
to var
. The latter is function-scoped, so it's visible outside the loop.