Events like user input, network calls, and file I/O are handled asynchronously by callbacks or "event listeners" on the next cycle of the event loop.
We can add an arbitrary event to the loop with
We typically have to know how an API works to know if a callback will be called synchronously or asynchronously (as part of an event handler in the future).
The execution order and error handling behavior of our code is different in each case.
Some APIs can also call a callback both synchronously and asynchronously, and we have to handle both.