heap.js
function(sort) {
  this._array = [];
  this._sort = sort;

  Object.defineProperty(this, 'length', {
    enumerable: true,
    get: function() { return this._array.length },
  });

  if (typeof this._sort !== 'function') {
    this._sort = function(a, b) {
      return a - b;
    }
  }
}
function(sort) {
  this._array = [];
  this._sort = sort;

  Object.defineProperty(this, 'length', {
    enumerable: true,
    get: function() { return this._array.length },
  });

  if (typeof this._sort !== 'function') {
    this._sort = function(a, b) {
      return a - b;
    }
  }
}
function ( sort ) { this . _array = [ ] ; this . _sort = sort ; Object . defineProperty ( this , 'length' , { enumerable : true , get : function ( ) { return this . _array . length } , } ) ; if ( typeof this . _sort !== 'function' ) { this . _sort = function ( a , b ) { return a - b ; } } }
heap.js
JS heap implementation
heap . js JS heap implementation