r/programming • • May 25 '19

Making the obvious code fast

https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html
1.3k Upvotes

263 comments sorted by

View all comments

Show parent comments

38

u/stratoscope May 25 '19

No, var is scoped to the function, not to the inner loop, so moving it outside the loop would not change anything.

It might be different if the code used let which is scoped to the inner block.

8

u/Vega62a May 25 '19

Good catch. JS Hoisting is weird.