Queue in Javascript: How to create Priority, and Circular Queue

Elson TC
Before Semicolon
Published in
9 min readApr 21, 2021

--

As you may have seen in the previous article, there are some limitations and things that can be improved about Queue. Sometimes you also need different constraints or rules around “enqueuing” and “dequeuing”. For those reasons, the Priority and Circular version of the Queue is available to address very specific situations.

Video Version of This Article

This post is an improved and more detailed article version of the Queue Data Structure Series on Youtube that you can check if you prefer videos.

Watch Videos

Priority Queue

A priority queue is simply a queue that cares about the priority level of the items. It is perfect when all you always want to address the most important items first. Whether you are creating a waiting list app for a hospital emergency room or a load balancer on your server or some sort of scheduler, this queue is perfect for you.

Note: Priority queue does not act on the FIFO principle enterily like you learned on the previous article. It acts on priority or level of importance of its items. If all items have the same priority, than it is First In First Out.

Higher priority means an item gets out of the queue first. Among the items of the same priority, the…

--

--

Elson TC
Before Semicolon

Software Engineer sharing knowledge, experience, and perspective from an employee and personal point of view.