Skip to main content

Understanding JavaScript Closures

Written by

in

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(); }

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *