There was a question while reading the js documentation section for addEventListener and removeEventListener.

Why use removeEventListener if we can remove / comment out the line where the handler is added using addEventListener?

  • one
    Well, let's say you added an event for an element, what if this event should be removed or disabled after any user actions? Will you comment it? - Klym
  • @Klym a, that is, say, an element reacts to the first click, then the events are deleted, and repeated presses will lead to nothing? I could not guess the practical application of this method, thanks - while1pass
  • Yes, you understood correctly. - Klym

0