The below method in pop() is not necessary
if (this.frequencyMap[num] > 1) {
this.frequencyMap[num] -= 1;
} else {
delete this.frequencyMap[num];
}
Because at worst the frequency will be zero and after that the elements is no more in heap.
If it’s found again then we just do the increment += 1. No harm done
Anyone else agree? Or Am I missing something?