# How do JavaScript closures work?

**URL:** <https://community.wowza.com/t/how-do-javascript-closures-work/48103>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-player-javascript-api\
**Created:** [February 1, 2017, 6:03am UTC](https://community.wowza.com/t/how-do-javascript-closures-work/48103 "2017-02-01T06:03:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alice\_cake](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@alice\_cake](https://community.wowza.com/u/alice_cake)\
**Post date:** [February 1, 2017, 6:03am UTC](https://community.wowza.com/t/how-do-javascript-closures-work/48103/1 "2017-02-01T06:03:31Z")

</div>

How would you explain [JavaScript](http://www.javascriptkit.com/cutpastejava.shtml) 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.

---

<div class="post-metadata">

**Author:** ![Jason\_Hatchett](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/jason_hatchett/32/391_2.png) [@Jason\_Hatchett](https://community.wowza.com/u/Jason_Hatchett)\
**Post date:** [July 21, 2017, 4:57am UTC](https://community.wowza.com/t/how-do-javascript-closures-work/48103/2 "2017-07-21T04:57:44Z")

</div>

Hello Alice,

In researching your question I found your StackOverflow post, and that is a better resource for a question of this nature.

Here is that post for others that may come across this forum post looking for an explanation:

[https://stackoverflow.com/questions/111102/how-do-javascript-closures-work](https://stackoverflow.com/questions/111102/how-do-javascript-closures-work)

Regards,  
Jason Hatchett  
Wowza Support Engineer
