Why Your JavaScript Loop Logs the Same Value Every Time (And How to Fix It)
It looks like a timing bug in setTimeout. It isn't. It's var's scope rules doing exactly what they're designed to do — and the fix is one keyword, once you know why.
Aug 29, 20264 min read


