Queues in Javascript
Queues are very similar to stacks. They’re sort of like a simpler version of arrays. You can think of them as like standing in line.
The first person in line is the first person to leave the queue. Thus, you can only shift
and push
to queues.
Queues follow the rule, first in, first out (FIFO). So when you shift
a queue, you remove the first item in the queue, and everything else shifts down the line. This is also known as dequeuing because you’re taking something off of the queue.
Pushing to a queue adds an item to the end. This is also known as enqueuing or adding an item to the queue.
If you understand arrays, you pretty much can grasp how queues work. Queues are just more restricted arrays, because you can’t insert items into the middle of a queue, and you can only shift
or push
to queues.
On another note, I am still job searching and Flatiron has been helpful in connecting me with companies for referrals. I am hopeful in my job search and hopefully will find a job soon amongst Covid times.
Stay safe, wash your hands, wear a mask if you do go out and keep 6 feet apart.