Events — Bubbling, Delegation and Cleanup — Concept Check
Questions on Events — Bubbling, Delegation and Cleanup. Events travel down to the target and back up again. Bubbling is what makes delegation possible, and delegation is what makes one listener handle a thousand rows.
Questions in this quiz
7 questions on Events — Bubbling, Delegation and Cleanup — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer attaches a click event listener to a parent element. What happens when a button inside it is clicked?
- AThe event is captured at the parent before reaching the button.
- BThe event bubbles up to the parent, triggering the listener.
- CThe event stops at the button and doesn't reach the parent.
- DThe event only triggers if the button has its own listener.
2.What is a key advantage of using event delegation on a list with many items?
- AIt reduces the number of event listeners needed.
- BIt requires each item to have its own listener.
- CIt prevents events from bubbling.
- DIt stops events from reaching the document level.
3.You add a click event listener with an inline arrow function. Why might this cause a problem when removing it?
- AInline functions automatically stop propagation.
- BInline functions prevent event bubbling.
- CThe inline function reference can't be reused for removal.
- DInline functions are more memory-intensive.
4.Which event does NOT bubble, potentially requiring a different handling approach?
- Afocus
- Bclick
- Cmouseover
- Dmouseout
5.In which scenario would using closest() in event delegation be beneficial?
- AWhen identifying which list item was clicked.
- BWhen preventing default browser actions.
- CWhen stopping an event from bubbling.
- DWhen capturing events before they reach the target.
6.What happens if you try to remove an event listener without the exact function reference?
- AThe listener is removed but re-attaches automatically.
- BThe listener remains active and is not removed.
- CThe listener is removed but stops event propagation.
- DThe listener is removed only during the capture phase.
7.Why might a developer use an AbortController when adding event listeners?
- ATo stop event bubbling.
- BTo prevent events from reaching the target.
- CTo remove multiple listeners at once.
- DTo ensure events only occur once.