Ah yes! Thank you serapath, I figured it out from what you said (and I 
really was being stupid!) To clarify for anyone reading:

the loop kicks off the callbacks, but they don't actually get executed 
until the loop has finished. By that point i is 3, and because it is 
effectively globally scoped, this is the value that is used by *all* of the 
callbacks in the loop.
The solution is to create a local scope for i.

Thanks for the feedback guys, and sorry again for the dumb question.

By the way, is 'a local scope for i' the same as 'a closure' ? I was under 
the impression these two things were not the same...?

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/5e9abfec-3881-4cf1-b974-a64374738f50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to