Queues

All about queues in Javascript


Queues are used to store data in a first-in, first-out (FIFO) order. This means that the first element added to the queue will be the first one to be removed.

We will use the following methods to implement a queue:

  • push: adds an element to the end of the queue
  • shift: removes the first element from the queue

push()

 

shift()