TE
TechEcho
Home
24h Top
Newest
Best
Ask
Show
Jobs
English
GitHub
Twitter
Home
Don't get bitten by Javascript variable hoisting in loops
4 points
by
ithayer
about 13 years ago
1 comment
Q_the_Novice
about 13 years ago
JavaScript variables are passed by reference, the variable `i` on the statement: `var msg = txt[i];` will always reference the last value after the loop has executed.