Javascript Closures
In this code snippet, we’ll learn about closures in Javascript. A closure is simply a function within a function. With this, we can achieve variable encapsulation. In other OOP languages, this would be done by making a private property inside a class. This way the variables inside are isolated and protected from the global space.