An event handler executes a segment of a code based on certain events occurring within the application, such as onLoad or onClick. JavaScript event handers can be divided into two parts: interactive event handlers and non-interactive event handlers. An interactive event handler is the one that depends on user interaction with the form or the document.