Priority Queue implemented as a BinaryHeap in JavaScript