In the following snippet, we are going to represent how JavaScript closures work. The easiest way of learning how to use them is investigating examples.