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.