Saturday, 15 August 2015

jquery - JavaScript Garbage Collection and Event Listeners -



jquery - JavaScript Garbage Collection and Event Listeners -

i'm using javascript oo pattern i'm declaring classes via prototypes:

function myclass(id) { this.id = id; ... } myclass.prototype.dostuff = function(json) { ...

and i'm instantiating class other classes:

new myclass();

upon construction class binds jquery event listeners perform actions:

this.$header = $('#myheaderid'); this.$header.on('click', $.proxy(myclass.prototype.dostuff, this));

i'm assuming if no js variable holds reference object event bindings keeping reachable. , if html element has event bound removed dom (via jquery's #remove, #empty etc), object unreachable , gced?

is assumption correct?

javascript jquery garbage-collection

No comments:

Post a Comment