I generate objects dynamically, and when they are created, I add click event listener to them:
let elements = document.getElementsByClassName("my-class")
for (let element of elements) {
element.addEventListener('click', function() {
// here I do my job
}, false)
}
After that, some objects may be deleted by the user. I take them off with this method:
element.remove()
And now I want to understand what happens next:
- Does this listener still exist? I hope that listeners became 1 less. But how to check it?
- Do I really need to worry about the large number of listeners? how large a number of listeners can become a problem? I’m afraid my app will break.