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?
大家讲道理2017-05-19 10:26:14
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.
伊谢尔伦2017-05-19 10:26:14
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.