Introducing events
In the real world, events are occurrences. For example, when you click a button, a click event is triggered. When you receive a message, a message received event is triggered. When you save a file, a file saved event is triggered. Events are present everywhere. In Node.js, events are also present everywhere.
So, when we talk about events in Node.js, we are talking about the same concept as in the real world. Events are occurrences, and we produce them or consume them. In some cases, one entity produces an event, and another entity consumes it. In other cases, the same entity produces and consumes the event. This can be very flexible; it is even possible that many entities consume the same event, or many entities produce the same event.
If you are familiar with the frontend world, you may have implemented handlers when a button is clicked, something like this:
document.getElementById('my-button').addEventListener('click', () => { &...