Does task queue(macro task queue) in Javascript Runtime Environment is a set data structure?

Viewed 143

Task queues are sets, not queues, because step one of the event loop processing model grabs the first runnable task from the chosen queue, instead of dequeuing the first task.

This is mentioned on whatwg website Link and I am unable to understand that why set data structure is used instead of queue.

1 Answers

Because in order to get picked, the task has to be runnable, and to be runnable, its document has to be fully active or null.

If they were actual queues, the distinction couldn't be done and tasks whose document is not fully active would get selected.

Related