
JavaScript Closure Stories part III  - skiskilo
http://tech.pro/tutorial/1771/javascript-closure-stories-iii
======
actsasbuffoon
If you use Array.map (or underscore's map, etc.) then you won't run into this
problem. The functional programmer in me gets a little angry whenever I see a
for loop in a language that supports higher order functions.

~~~
malandrew
I just wish JavaScript map was more powerful. I like that underscore's map
provides a bit more information passed to the mapped function. It would also
be nice if there was an object map function built into the language as well.
Again underscore has a solution but the core prototypical functions lack here.

It would be awesome if many of the solutions in underscore and other high
quality functional libraries could be added to the native prototypes.

------
kelmop
I understand first and second example, but not the third.

Someone care to explain? You can assign value for card but no read at the same
line?

Once I though that I understand something but I was wrong :)

~~~
nadinengland
Closure allows you to capture references to variables, not objects.

The function may reference the variable `card` but by the time the first one
is triggered the for-loop had already decremented the variable to 0.

~~~
kelmop
Thanks!

I think that I will stick with this: "You should stick with the simple stuff
from now on. Capisce?"

