Closure in js
A closure is a combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment).
function init() {
var name = 'Mozilla';
function displayName() {
console.log(name);
}
displayName();
}
init();
frontendblogs.hashnode.dev1 min read