I know for sure that it is a good practice to remove a
listener when it is not going to be used anymore. However, will
addEventListener cause any problem if the same event has been added
to a listener already? And how?
hasEventListener can be used to detect whether an event has
been added to a listener but I don't know how many times it has
The documentation specifies what happens very well. Take a
look at any object that has the addEventListener method. here is
the part that answers your question.
After the listener is registered, subsequent calls to
addEventListener() with a different value for either type or
useCapture result in the creation of a separate listener
registration. For example, if you first register a listener with
useCapture set to true, it listens only during the capture phase.
If you call addEventListener() again using the same listener
object, but with useCapture set to false, you have two separate
listeners: one that listens during the capture phase, and another
that listens during the target and bubbling phases.