Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference between event loop and task queue in browsers?

I am a little confused about some terms in the answer of this question: What is the event precedence in JavaScript?

Is there a difference between event loop and task queue and how big are can these queues?

Because when I have set an Interval with setInterval() and interrupt this with an alert() then the intervals are dropped for the time where the alert is showing up.

like image 875
krema Avatar asked Dec 27 '22 08:12

krema


2 Answers

Heap : Stores All variables , Objects , Functions and To all this memory is allocated

Event Queue : He is the person contains list functions TOBE EXCECUTED By Stack.

Stack : He is the main person who EXECUTES FUNCTIONS held by Event queue

Event Loop :

  1. He is the person(manager) who is in contact with Event Queue And Stack.

  2. What he does Is .Ifff The stack is empty and Event Queue Contains Functions to execute.then push the first function from Event Queue to stack

visual Example 1 : latentflip

like image 147
vijay Avatar answered Dec 30 '22 10:12

vijay


This is an implementation detail - the specification is saying that an event loop can be use multiple task queues to store events. Presumably there is no practical limit to the size of the queues.

For example, mouse/keyboard events could go into a special INPUT task queue that has a higher priority than other tasks, perhaps to make the UI more reponsive.

alert will interrupt the processing of events because it is a synchronous operation. Presumably any applicable events would be queued in the meantime.

like image 23
Justin Ethier Avatar answered Dec 30 '22 10:12

Justin Ethier