Reputation: 23634
(function(){
var a;
function inner1(arg){
a = arg;
}
function inner2(){
alert(a);
}
})();
Will this cause memory leak in my application, since i am declaring variable a outside my other two inner functions.
Upvotes: 0
Views: 221
Reputation: 11958
No, because you are declaring that variable inside an anonymous function closure already.
You can prove this by doing the following.
(function(){
var a;
function inner1(arg){
a = arg;
}
function inner2(){
alert(a);
}
})();
alert(a)
Upvotes: 2