For some time I've had a doubt about js potential memory leak in this type code:
function foo() {
var a = "This is my content";
$('#myElemId').on('click', function() {
$(this).html(a);
});
}
My question is:
When foo is called, I suppose it is created an execution object, allocates memory for var a and assigns an event listener to a dom element. Once foo returns it should free the execution object but I think it won't because there is still a reference to var a from the click listener, right?