'WEB APIs environment

I am trying to understand the internal working process of the JS browser environment and so far everything seems to be reasonable. Just one thing that I do not fully get is how WEB APIs internally handle all the asynchronous code and event listeners. I mean abstractions like event handlers are registered in the WEB APIs environment are okay to understand the concept and may be it is not required for the developers to know more to write a code, but, several questions still bother me. For instance, does the WEB APIs environment has its own engine, which handles all these asynchronous tasks and fires events when it is necessary to do? The fact that event handlers are placed in the callback/message queue when a certain event is fired means that some function in the WEB APIs environment takes care of that and executes to perform these action right? Also, does the fact that these callbacks are stored in the WEB APIs environment mean that environment has its own heap-like structure?

Thanks in advance. In case you have some learning materials on that do not hesitate to provide them ^_^



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source