DEV Community

Naveen Dinushka
Naveen Dinushka

Posted on

Creating a Queue in JS

  1. Queue data structure can be thought of as a container where records enter on one end and exit on the other
  2. Process of adding something to queue is something called 'Enqueuing or adding' , removing something from a queue is also called 'Dequeuing'
  3. Queue follows First In First Out principal

Before we go ahead and write a Queue we should understand the following concepts in JS

  1. Unshift method, adds something in front of the JS array
  2. Pop method , removes something from the end of the JS array

So the Queue basically limits access to so many options like shift, unshift, push, splice and slice in JS and only allows shift and pop.

Top comments (0)