Javascript implementation of Binary heap data structure