A closure is the combination of a function bundled together with references to its surrounding state. In other words, a closure gives an inner function access to the outer function’s scope.function init() { var name = 'Mozilla'; function displayName() { console.log(name); } displayName(); }
Understanding JavaScript Closures

Leave a Reply