JavaScript click handler not working as expected inside a for loop [duplicate]
This question already has answers here: How do JavaScript closures work? (86 answers) Closed 8 years ago. I’m trying to learn JS and got an issue. I tried many things and googled but all in vain. Following piece of code doesn’t work as expected. I should get value of i on click but it always … Read more