What are the different ways to handle events in JavaScript?

Beginner

Answer

// HTML attribute
<button onclick="handleClick()">Click</button>
// DOM property
button.onclick = function() { };
// addEventListener (recommended)
button.addEventListener('click', function() { });