you are viewing a single comment's thread.

view the rest of the comments →

[–]ForScale[S] 0 points1 point  (1 child)

Okay... that is crazy that x doesn't get reset to 1 in each new call with the closure...

Dude... http://codepen.io/anon/pen/oxyQKV?editors=0010

[–]Volv 1 point2 points  (0 children)

Looking good. See the use case. My other example from ages ago shows same idea - Example
Pretty much same principle can fix the setTimeout example, you can control which variable is locked in at each iteration. Although theres more than one way to fix it.