Presumably there is a way to invoke
myEvent.Stop()
which would presumably call clearInterval
or whatnot, but it depends upon said interface exposed.
JavaScript is fully garbage-collected and there is no implicit (or explicit) destructors. All "cleanup" (such as Stop
), if required, must be done explicitly.
There is no way to "delete" an object, only to let it become unreachable in which case the GC may reclaim ("destroy") it if it feels like it -- however both setInterval
and setTimeout
will maintain a strong reference to the callback which 1) will fire the callback even if the callback and/or myEvent
is not strongly reachable elsewhere 2) may prevent other objects from being eligible for reclamation if they are reachable via the callback.
Happy coding.
See Garbage Collection: Reachability of an Object.