There is a question that I have been holding back for a long time:
If you do not use event delegation, many people write like this (as shown above), looping the click event.
My question is:
Writing it this way is less code than writing it three times just for the page?
Or is the performance better? The good thing?
The code is less, more elegant, and there is not much difference in performance. But when writing like this, you have to be careful about the closure problem, that is, when the function uses i, you know.
It’s just less code
The performance is the same
The logic is simple and less error-prone, which increases overhead, but is generally not enough to affect performance. If the handler is taken out separately, the impact will be smaller.
The operation is the same, there is a loop, but the code is reduced.