Assume that, I have following a codes in document.ready event
$(function(){
var a=1;
$("#btn").on("click",function(){
a++;
var b=1;
function foo(){
alert(a*b);
b++;
}
}
}
In this case, what is the life time of variable 'a' and 'b'. Is new 'b' allocated in every call of click event and previous b deleted by garbage collector?