Re:JS Visualizer – Visualize Context, Hoisting, Closures, an...
by jazzyjackson on Tuesday October 09, 2018 @10:07PM
(#18181453)
This is not a bug, this is spec.
variables in javascript are not block scoped, but functionally scoped.
the let keyword introduces block scope to javascript.
For example this doesn't print what you expect:
But flipping var to let will fix it. The bug is that var is not block-scoped so everything refers to the same `text` variable which gets mutated by the next iteration.I was hoping their demo would be good for explaining this bug but it seems to be broken.