I completely get this part that I have access to the variables/functions defined in its parent scope but when do we need this?
Closure in a Language is a powerful feature. In ECMAScript, the functions are considered as a first-class object. This means a function can be passed as a parameter to a function and a function can be returned from a function.
- Accessing private variables and methods
- Closure can be used to do module design pattern
- Closures can be used in functional template