How do JavaScript closures work?

Talk about add-ons and extension development.
Post Reply
alicemike
Posts: 1
Joined: February 1st, 2017, 4:34 am

How do JavaScript closures work?

Post by alicemike »

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.
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: How do JavaScript closures work?

Post by lithopsian »

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.
Post Reply