JavaScript Binary Heap