If I want to save on memory, does an event listener need to be deleted from an element if the element is already deleted. If I do something like this:
temp_canvas = document.createElement('canvas');
temp_canvas.id = 'temp_canv';
$("#temp_canv").mousedown(e => {this.line_down(e);});
document.getElementById("temp_canv").removeEventListener('mousedown', line_down(e));
Does this remove the memory of the event listener along with the canvas element?
Thanks
They only stay in memory if there are references to said element. See this answer .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.