Don't get bitten by Javascript variable hoisting in loops
thecomputersarewinning.com
Don't get bitten by Javascript variable hoisting in loops
1–2 of 2 posts
Re: Don't get bitten by Javascript variable hoisting in loops
#2JavaScript 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.