Removing Event Handlers

removeEventListener() succeeds only when the type, the same function reference and the capture flag all match, so an anonymous listener cannot be removed:

The capture flag must matchCSS
btn.addEventListener("click", onTap, { capture: true });
btn.removeEventListener("click", onTap);        // no effect: capture flag differs
btn.removeEventListener("click", onTap, true);  // removed

No standard API lists or clears all listeners. el.replaceWith(el.cloneNode(true)) drops every listener added by script, but other code may still hold the detached original, so prefer once or a shared signal.