What is the use of custom events in javascript?

  node.js, question

Seeing that there are custom events in js,
It seems to simulate user behavior, such as clicking, keyboard, etc.
Of course, you can also create your own events.
But can’t I just call related functions in js to achieve this goal?
Making an event yourself is basically the same as writing a named function (except for event).
So what is the meaning of the existence of custom events and what is their use? For writing test scripts for testers?
Manage events and event functions?

This usage is still a lot, when making wheels, it can be used to handle some event monitoring operations. For example, you can encapsulate an ajax usage like this:

Ajax.open(…)
 Ajax.on("success",function(){
 //do
 })
 Ajax.on("error",function(){
 //do
 })

Is this a good way to use it?
For such usage, there are many in node asynchronous programming, such as fs module, http module, etc.
Oh, by the way, this usage is called event publish/subscribe, which is an asynchronous programming method.