Shared publicly  - 
 
Scopes and Closures In-depth Unit 2: Compilation and Interpretation
This course covers two important concepts of the JavaScript programming language - scopes and closures. In this course, you'll understand how variable scoping work in JavaScript. You'll also understand what closures are and how to use them in your code.
6
Jeff Schwartz's profile photoJava Brains's profile photo
 
Your explanation of why the var i was always 10 in your closure tut was wrong. It isn't because there is only one var i. It was always 10 because the timer callbacks only got called after the for loop had completed and at that point i had been incremented to 10. The for loop runs synchronously while the timer callbacks run asynchronously. As the JavaScript runtime is single threaded, any asynchronous action will be delayed until either all synchronous activity has ended or yield is called.

Understanding the above is imperative for any novice JavaScript developer or teacher.
Add a comment...