Nodejs Array Min min()

Here you can find the source of min()

Method Source Code

function Calculator(array){      
   var self = this;

   (function(array){
      self.min = array.min();//  w w  w  .  j av a2s . c  om
      self.max = array.max();
      self.avg = array.avg();
   })(array);
}

Array.prototype.min = function(){
   return Math.min.apply(null, this);
};

Array.prototype.max = function(){
   return Math.max.apply(null, this);
};

Array.prototype.avg = function(){
   return this.reduce(function(c,p){ return c + p; })/this.length;
};

Related

  1. min()
    Array.prototype.min = function() { 
      return Math.min.apply(null, this) 
    
  2. min()
    Array.prototype.min = function(){
      return Math.min.apply({},this)
    
  3. min()
    var min = Math.min.apply(null, arr),
        max = Math.max.apply(null, arr);
    Array.prototype.min = function() {
      return Math.min.apply(null, this);
    };
    
  4. min()
    Array.prototype.min = function () {
      "use strict";
      return Math.min.apply(null, this);
    };
    
  5. min()
    Array.prototype.min = function() {
      return Math.min.apply(Math, this);
    };
    
  6. min()
    Array.prototype.min = function() {
      var r = null;
      for (var i = 0; i < this.length; i++) {
        if (r === null || this[i] < r) {
          r = this[i];
      return r;
    };
    ...
    
  7. min()
    Array.prototype.min = function(){
       var min=this[0];
       this.forEach(function(v){min=(v<min)?v:min;});
       return min;
    };
    
  8. min()
    maxNum([1,2,3]);      
    maxNum([10,3,10,4]);  
    maxNum([-5,100]);      
    function minNum(arr) {
      var len = arr.length;
      var min = Infinity;
      while (len--) {
        if (arr[len] < min) {
          min = arr[len];
    ...
    
  9. min()
    Array.prototype.min = function() {
      var min = this[0];
      var len = this.length;
      for (var i = 1; i < len; i++){
        if (this[i] < min){
          min = this[i];
    return min;
    ...