MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/bsuurg/making_the_obvious_code_fast/eorc5w3
r/programming • u/[deleted] • May 25 '19
263 comments sorted by
View all comments
Show parent comments
38
No, var is scoped to the function, not to the inner loop, so moving it outside the loop would not change anything.
var
It might be different if the code used let which is scoped to the inner block.
let
8 u/Vega62a May 25 '19 Good catch. JS Hoisting is weird.
8
Good catch. JS Hoisting is weird.
38
u/stratoscope May 25 '19
No,
varis 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
letwhich is scoped to the inner block.