Any data from the server is requested asynchronously: a request is sent (XMLHttpRequest or XHR), and the code📟 does not wait for its return🔄, continuing to execute. When the server responds, the XHR object is notified of this and runs the callback function that was passed to it before sending the request.
If you use the language tools correctly👅, then the execution of a request, which occurs sequentially and in one thread, does not interfere in any way with the reception of events and the reaction to them - a person👨 calmly works with the interface, not noticing lags, crashes and freezes.
Event loop is an asynchronous call manager.
loop translates as" loop ", which perfectly reflects the meaning: we are dealing with a loopback queue.
Event loop regulates the sequence of execution of contexts - the stack. It is generated when an event was triggered or a function was called. The response to the event is placed in the execution queue, in the
event loop, which sequentially, with each loop, executes the code that gets into it📟. In this case, the function bound to the event is called next after the current execution context.
stack - forms a queue and forwards to asynchronous -
event loop - function calls⚙️ that will be executed after the currently scheduled executable context.
Thanks goes to these wonderful people (emoji key):