dom-eventsmedium
Explain event bubbling, and how delegation uses it.
Answer
An event first travels down from the root to the target (capturing), fires on the target, then travels back up through the ancestors (bubbling). Delegation exploits the bubbling phase: instead of a listener per item, you put one on a shared parent and read event.target to find what was actually clicked. That keeps memory flat and — crucially — keeps working for items added to the DOM later.
Points an interviewer listens for
- Capture down, fire on target, bubble up
- One parent listener instead of one per child
- Works for dynamically added elements
- event.target is the source; currentTarget is the listener's element
Reported at
Similar questions have been reported by candidates at Northcorp Software, Accenture, Helpshift, Mundrisoft Solutions, Nielsen, PayPay Corporation.
Now try answering it out loud
Interview practice mode times your spoken answer and checks it against the points above.
Practise this question