15

Reading through a lot of JavaScript Event Loop tutorials, I see different terms to identify the queue stores messages ready to be fetched by the Event Loop when the Call Stack is empty:

  • Queue
  • Message Queue
  • Event Queue

I can't find the canonical term to identify this.

Even MDN seems to be confused on the Event Loop page as it calls it Queue first, then says Message Queue but in the tags I see Event Queue.

Is this part of the Loop being defined somewhere in details, or it's simply an implementation detail with no "fixed" name?

1
  • 1
    Yes, how the queue is constructed exactly (and how many queues of there are for messages of different priorities) is an implementation detail. Commented Apr 9, 2018 at 11:20

1 Answer 1

16

Good question, I'm also a advocate of using proper terminology.

Queue, message queue, and event queue are referring to the same construct (event loop queue). This construct has the callbacks which are fired in the event loop.

Interestingly there are two different queues the job queue and the event loop queue. The job queue is specifically designed for promises. The job queue has a higher priority than the event loop queue, so if there are both callbacks available in both queues the ones in the job queue will be put on the stack first.

Hopefully this answers your question.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.