Value type stored in the queue.
Removes and returns the value at the front of the queue.
Front value, or undefined when the queue is empty.
Adds a value to the back of the queue.
Value to enqueue.
This queue instance.
Reads the value at the front of the queue without removing it.
Front value, or undefined when the queue is empty.
Reads the value at the back of the queue without removing it.
Back value, or undefined when the queue is empty.
First-in, first-out queue.
Remarks
The constructor reverses the provided initial array in place so the first input element can be dequeued first. Use a copied array when the original order must be preserved outside the queue.
Example