Queue

var q = Queue() // Create a new Queue

q.enqueue(4)
q.enqueue(1) // add elements to queue
q.enqueue(7)
q.enqueue(3)
q.enqueue(9)

q.dequeue()
q.dequeue()
q.dequeue() // remove elements from the queue

console.log(q.isEmpty()); // true if there are no elements in the queue
console.log(q.peek()); // displays top of the queue

Priority Queue

// Create a new priority queue
var q = PriorityQueue()

q.enqueue("this",4) // add elements to queue
q.enqueue("that",1)
q.enqueue("here",7)
q.enqueue("there",3)
q.enqueue("where",9)

q.dequeue()
q.dequeue() // remove elements from the queue

console.log(q.isEmpty()); // true if there are no elements in the queue
console.log(q.peek()); // displays top of the queue