Hi I was going through closure concept in JavaScript. I am finding it difficult to understand it. Can someone please help me?
function a(name) {
return function () {
console.log( "Hello "+ name);
}
}
var b = a("MyName");
b();
According to closure, inner function will have access to its outer function's variables even after the execution of outer function is compeled and it's no more present in stack. Can some one please explain how inner function is able to access its variable even after execution for outer function is completed. I have tried above code and it's working as expected but I am confused?