I understand the concept of circular references in JavaScript and the importance of avoiding them to prevent memory leaks, but I have not been able to find any information about how assigning functions that are members of closures or prototypes to event handlers impacts garbage collection.
For example let's say I wrote either one of the following:
var o = {};
o.var = 10000000;
o.func = function() { /*Do something that does not involve o.var*/ };
function p() { }
p.prototype.var = 100000;
p.prototype.func = function () { /*Do something that does not involve p.var*/ };
... and then proceeded to do either one of these:
var div = document.getElementByID('div');
div.onclick = o.func;
var instance_of_p = new p();
var div = document.getElementByID('div');
div.onclick = instance_of_p.func;
Would the assignment of func() to a DOM event handler prevent the entire object from ever be collected by the GC?