Understanding JavaScript Closures

Closures are objects that contain a function and a reference to the environment in which the function was created. They are a language construct, which allows developers to preserve the state of the variables and thus prolong the scope.
Let’s look at a basic example:

Link: https://dzone.com/articles/understanding-javascript-closures?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev