JavaScript · Junior · Question 43 of 75
What is event delegation about?
- ✓Correct answer: One handler on a parent handles children's events via
event.target - 2The handler is moved to a Web Worker so it doesn't block the main thread
- 3Each child element gets a copy of the parent's handler
Explanation
Instead of 1000 handlers on every table row, there's one on table that finds the target via event.target.closest('tr'). This saves memory and automatically works for elements added later. It relies on bubbling.