How do JavaScript closures work?

How do JavaScript closures work? – Stack Overflow.

JavaScript is an amazing tool, as evidenced by not only its explosion the past few years, but also the sheer number of highly technical blog articles and posts like these coming out.

Closures in JavaScript are often a topic of discussion. It’s often very confusing to those JavaScript writers who are looking to move beyond jQuery and really start to learn JavaScript itself.

There’s a lot of good information in that thread, but I’m really liking the (currently) top voted explanation.