How would you explain Javascript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves?
I have seen the Scheme example given on Wikipedia, but unfortunately it did not help.
How do JavaScript closures work?
-
- Posts: 3664
- Joined: September 15th, 2010, 9:03 am
Re: How do JavaScript closures work?
Rather than get quick scribbles here, it might be best to browse the many (many!) web pages that discuss closures. One of them might just do it in the right way for you. Another good way is to actually run some closure code and look at the results - can be baffling at first, but when you see it in action it is illuminating. Then maybe if you have specific questions, I'm sure someone here will know.