How can we handle events in JavaScript?

In JavaScript, how can we handle events?

There are several approaches for allowing JavaScript to deal with events: HTML event properties can directly run JavaScript code.

JavaScript functions can be called by HTML event properties. HTML components can be assigned your own event handler functions.