MozillaZine

How do JavaScript closures work?

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

Post Posted February 1st, 2017, 4:41 am

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: 3662
Joined: September 15th, 2010, 9:03 am

Post Posted February 1st, 2017, 7:08 am

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.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 3 guests