0Pricing
JavaScript Academy · Lesson

Custom Events

Create and dispatch your own events.

Beyond Built-In Events

The DOM lets you create and dispatch your own events with CustomEvent. This decouples parts of your app: one component announces something happened, others listen without a direct reference.

Creating a CustomEvent

Construct one with new CustomEvent(name, options). The name is any string you choose.

const evt = new CustomEvent("cart:add");
console.log(evt.type); // "cart:add"

All lessons in this course

  1. The Capture and Bubble Phases
  2. Event Delegation Pattern
  3. Dynamic Lists with Delegation
  4. Custom Events
← Back to JavaScript Academy