Question Bank

Event Delegation and Event Bus Quiz

Difficulty: Medium

Practice DOM event delegation, build a minimal pub/sub event bus, and roll your own dispatcher so cross-component communication stays decoupled.

Question Bank
/

Event Delegation and Event Bus Quiz

Event Delegation and Event Bus Quiz

Practice DOM event delegation, build a minimal pub/sub event bus, and roll your own dispatcher so cross-component communication stays decoupled.

Question Bank
Medium
JavaScript
4 questions
quiz
js-event-delegation
js-dom
design-patterns

569 views

10

Attach a single click listener on #parent that uses event delegation to log the text of any clicked .child button. Don't add per-button listeners.

Examples

Example 1:

Input: user clicks button with text 'Button 2'
Output: 'Button clicked: Button 2'
Explanation: The click bubbles up to `#parent`; the listener checks `e.target.matches('button.child')` to filter.