I have an app where the user can create and destroy graphical objects. Each one of these objects spawns multiple event listeners. When the object is destroyed (removed from the DOM), do I have to remove all of those event listeners? What could happen if I don't?
The event listeners in this case are mousedown
and mouseup
on the object itself, and mousemove
on the document body, but what's best practice in the general case.