Since we know local variable of normal function dies or garbage got collected after the function finishes the execution?
So in case of closure When and how outer function local variable dies? as Closure have access of local variables of outer function.
(function outer(args) {
var greet = "hello";
//return inner();
function inner() {
console.log("inner function / closure " + greet + " " + args);
}
})("hi");
When the outer function finish its execution, will the greet variable dies or its garbage will be collected? since it is being used in inner function.
After Edit: Actually my question concern is, we all read when function finishes its execution local variable got garbage collected or free its memory.
In case of closure any how if inner function is going to use outer function's local variable then this concept got failed ?