Events are the signals that something has happened in the browser. From a mouse click to a window resize, events allow your JavaScript to react to the world around it.
1The Listener Protocol
Modern JavaScript uses the addEventListener method to connect code to interactions. This approach is superior to inline HTML attributes because it allows multiple listeners for the same event and provides a clean separation of concerns. Every listener receives an Event Object, a rich payload of data that identifies the target element, the specific key or mouse button used, and even the exact coordinates of the interaction.
2The Propagation Flow
Events in the DOM don't just stay where they started; they Bubble up through the tree from the target to the root. Understanding this flow is essential for Event Delegation—a performance pattern where you attach a single listener to a parent container to manage events for all its children. This 'bubble' can be surgically halted using e.stopPropagation() when you need to isolate an interaction from its surrounding environment.
