I’ll translate the full article, preserving its conversational tone, structure, and code ...

I’ll translate the full article, preserving its conversational tone, structure, and code examples.I’m preserving the article’s original technical claims and compatibility notes, and translating the code comments alongside the prose.# Hooray! Browsers Now Natively Support ES6 `ex...

Code: Dispatching a CustomEvent

const event = new CustomEvent('show', {
  detail: { message: payload, sentAt: new Date().toLocaleTimeString() }
});

window.dispatchEvent(event);
Result
Waiting for an event...

Code: Listening for the Event Payload

window.addEventListener('show', (event) => {
  render(event.detail.message, event.detail.sentAt);
});
Event log
No events yet.