Hello guys…my turn to ask a question. Will the following code leak memory?
[CODE]someElement.onmousedown =
function(e) {
var tmp = this;
var tmpFnc = function(e){tmp.removeEventListener(“mouseup”,arguments.callee,false);};
this.addEventListener(“mouseup”,tmpFnc,false);
};
someElement is pressed causing an eventlistener to be attached for when the element is depressed. When the element is depressed the closure will remove the eventlistener for the mouseup event.
Second question. Is the above identical to
[CODE]someElement.onmousedown =
function(e) {
var tmp = this;
this.addEventListener(“mouseup”,function(e){tmp.removeEventListener(“mouseup”,arguments.callee,false);},false);
};
Does it make a difference whether a reference to a closure is stored in a variable or not?