Hacker News new | comments | show | ask | jobs | submit login
Don't get bitten by Javascript variable hoisting in loops (thecomputersarewinning.com)
4 points by ithayer 2060 days ago | hide | past | web | favorite | 1 comment



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.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: