I am a little confused about these two names,are they the same with each other?
- See stackoverflow.com/questions/40880416/…, I think your question is a duplicate of that one.SteveB– SteveB2019-03-04 14:42:15 +00:00Commented Mar 4, 2019 at 14:42
- 1stackoverflow.com/questions/49729247/… and stackoverflow.com/questions/40880416/… could be helpful . Maybe also developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoopADyson– ADyson2019-03-04 14:42:22 +00:00Commented Mar 4, 2019 at 14:42
- No a duplicate,they didnt mention task queue which appear in some blogsChor– Chor2019-03-04 14:46:58 +00:00Commented Mar 4, 2019 at 14:46
- No-one nominated the above as duplicates, just maybe as potentially interesting or useful reading material to explain the concepts in this area. Which blogs are you seeing "task queue" in...not sure that's a correct/formal piece of terminology being used by the Javascript standardsADyson– ADyson2019-03-04 15:19:56 +00:00Commented Mar 4, 2019 at 15:19
- 2An event is something that must be handled, a task is something that can be run. The two terms might accurately describe the kind of data structure that a particular implementation is queueing, or they might be used sloppily and refer to the same thing. After all, an event to trigger a task and a task to handle an event are interchangeable.Bergi– Bergi2019-03-04 15:44:55 +00:00Commented Mar 4, 2019 at 15:44
1 Answer
There is no "event queue" in ECMAScript, there is also no "event loop" and no "task queue".
The ES262 specification only says:
8.4 Jobs and Job Queues
A Job is an abstract operation that initiates an ECMAScript computation when no other ECMAScript computation is currently in progress. A Job abstract operation may be defined to accept an arbitrary set of job parameters. Execution of a Job can be initiated only when there is no running execution context and the execution context stack is empty. A PendingJob is a request for the future execution of a Job
[...]
A request for the future execution of a Job is made by enqueueing, on a Job Queue, a PendingJob record that includes a Job abstract operation name and any necessary argument values.
In ECMAScript, there are only two Job queues, one for promise resolution and one for the initial loading of modules / code, however the spec allows more queues to be defined explicitly.
Everything else is not defined by ECMAScript itself, but is defined by the runtime implementations or by other specifications.
The "task queues" you were talking about are an example for that:
They are defined for webrowsers as ES job queues for browser specific events. This Specification also coins the term "event loop" (which is also a common term) to describe the logic that empties the job queues.
Therefore "event queue" is probably used because
a) it simplifies the concept of multiple job queues if you say that there is "one event loop" that empties "one event queue".
b) people never read the specs.
c) the term was coined and never specified.