A Simple Closure Example

Clement Hoang
4 min readDec 31, 2014

Ah, the night before New Years, the perfect time for programming. Recently, I have been brushing up on my Javascript coding in preparation for my co-op term and revisited closures. Closures are a very powerful feature of Javascript, albeit one that is quite tricky to understand at first. Below is an excerpt from Jibbering that aims to define closures in a couple of paragraphs.

Closures are one of the most powerful features of ECMAScript (javascript) but they cannot be properly exploited without understanding them. They are, however, relatively easy to create, even accidentally, and

--

--

Clement Hoang

Previously worked on React at Facebook and UWaterloo alumnus. Current engineer at Credit Karma. Learn about me on clementhoang.net.