2
input.addEventListener('keydown', function (event) { if (event.key == "Enter") {input.remove()} } );

I wonder, if it is necessary to add input.removeEventListener() in such situation, or EventListener will be removed automatically?

Pointy
  • 405,095
  • 59
  • 585
  • 614
  • 1
    Does this answer your question? [Do I need to remove event listeners before removing elements?](https://stackoverflow.com/questions/6033821/do-i-need-to-remove-event-listeners-before-removing-elements) – Fcmam5 Mar 05 '23 at 18:45
  • @Fcmam5 the answers to the other question hasn't been updated for some time – Konrad Mar 05 '23 at 19:47
  • I always thought the EventTaget couldn't be garbage collected while having event listeners attached to it, but the linked response seems to prove that's not the case and we can (or can we?) only assume the situation has improved since 2016. – Sheraff Mar 05 '23 at 20:26

0 Answers0