Heap Implementation in JavaScript