JS Built-ins
Eventbeginner

Event Constructor β€” bubbles:true option

πŸ“– Usage Example
const target = new EventTarget()
const e = new Event('ping')
target.dispatchEvent(e)  // dispatches the event

Use dispatchEvent() to fire a custom event on any EventTarget.

Event β€” bubbles option

Passing { bubbles: true } as the second argument to new Event() creates a bubbling event.

Challenge: Verify that new Event('x', { bubbles: true }).bubbles is true.

πŸ’‘ Hints (1)
  • β€’ The second argument to new Event() is an EventInit dictionary