Showing archive results for June 5, 2014

Jun 5, 2014
Post comments count0
Post likes count1

Closing over the loop variable is just as harmful in JavaScript as it is in C#, and more cumbersome to fix

Raymond Chen

Prerequisite reading: Closing over the loop variable considered harmful. JavaScript has the same problem. Consider: The most common case where you encounter this is when you are hooking up event handlers in a loop, so that's the case I used as an example. No matter which button you click, they all alert , rather than the respective button ...

Code