Interview Question

What is event capturing?

Capture delivers events from ancestors toward the target before bubbling.

💡 Concept ✅ Quick Revision ⚡ JavaScript

Answer

Event capturing is the phase where listeners run along the event path before the target phase. • A listener opts into capture with the capture option. • The path proceeds from outer ancestors toward the target. • Capture is useful when an ancestor must observe an event before target and bubble listeners.

Example

Code
document.addEventListener('click', handleClick, { capture: true });

Quick Revision

Capture delivers events from ancestors toward the target before bubbling.