Nodejs Array Max max(c)

Here you can find the source of max(c)

Method Source Code

Array.prototype.max = function(c) {
        c = c || function(a, b) { return a > b ? a : b; };
        m = this[0];//w w w.jav  a2 s. c o m
        for(var i = 1; i < this.length; i++) {
                m = c(this[i], m);
        }
        return m;
};

Related

  1. max()
    Array.prototype.max = function() {
        var length = this.length;
        var max = this[0];
        for ( var i = 0; i < length; i++ )
            var elem = this[i];
            if ( elem > max ) max = elem;
        return max;
    
  2. max()
    Array.prototype.max = function() {
      var maxval = 0;
      for (var i=0; i<this.length;i++) {
        var val = Number(this[i]);
        if (!isNaN(val)) {
          maxval = Math.max(maxval, val);
      return maxval;
    ...
    
  3. max()
    Array.prototype.max = function() {
      var max = -Infinity;
      for (var i = 0; i < this.length; i++) {
        if (typeof this[i] === "number" && this[i] > max) {
          max = this[i];
      return max;
    };
    ...
    
  4. max()
    Array.prototype.max = function() {
      if (this.toNumsOnly().length == 0) return undefined;
      return Math.max.apply(null, this.toNumsOnly());
    };
    
  5. max(array)
    Array.max = function( array ){
        return Math.max.apply( Math, array );
    };
    
  6. max(comparer)
    Array.prototype.max = function(comparer) {
        if (this.length === 0) return null;
        if (this.length === 1) return this[0];
        comparer = (comparer || Math.max);
        var v = this[0];
        for (var i = 1; i < this.length; i++) {
            v = comparer(this[i], v);
        return v;
    ...
    
  7. max(fun)
    Array.prototype.max = function (fun) {
        var max = this[0];
        this.forEach(x => {
            if (fun ? fun(max, x) : (max < x))
                max = x;
        });
        return max;
    };
    
  8. max(func)
    Array.prototype.max = function (func) {
        return func === undefined ? Math.max.apply(null, this) : Math.max.apply(null, this.select(func));
    };
    
  9. max(k)
    Array.prototype.max = function (k) {
      return Math.max.apply (null, this.column (k));
    };