Here you can find the source of removeMax()
// remove the max and min value from array, and the value may be duplicated. var a = [2,12,34,4]; Array.prototype.removeMax = function(){ var max1 = Math.max.apply(null,this); var pos = this.indexOf(max1); return this.splice(pos,1); } a.removeMax();// www . j a v a 2 s .c o m