# Introduction to ES6 Math Methods and New Number Features

# Introduction to ES6 Math Methods and New Number Features ## 1. The Math Object in ES6 The global object `Math` gained several new methods in ES6. First, let’s look at various numeric utility methods. ### Math.sign(x) The `Math.sign()` function returns the sign of a number, ind...

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.