Nodejs Array Min min()

Here you can find the source of min()

Method Source Code

Array.prototype.min = function(){
    var i, min = this[0];
    for (i = 1; i < this.length; i++){
        if (min > this[i])
            min = this[i];//from   w  ww .  java2 s . com
    }
    return min;
};

Related

  1. min()
    Array.prototype.min = function(){
       var min=this[0];
       this.forEach(function(v){min=(v<min)?v:min;});
       return min;
    };
    
  2. 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];
    ...
    
  3. 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;
    ...
    
  4. min()
    Array.prototype.min = function() {
      return this.reduce(function(p, v) {
        return (p < v ? p : v);
      });
    
  5. min()
    Array.prototype.min = function() { 
       return Math.min.apply(null, this); 
    };
    Array.prototype.diff = function(a) {
        return this.filter(function(i) {return i!=a;});
    };
    
  6. min()
    Array.prototype.min = function() {
        return Math.min.apply(Math, this);
    };
    
  7. min()
    Array.prototype.min = function() {
      return Math.min.apply(null, this);
    };
    Array.prototype.remove = function(index) {
        this.splice(index, 1);
    };
    
  8. min()
    Array.prototype.min = function () {
        return this.reduce(function(previousValue, currentValue) {
            return previousValue < currentValue ? previousValue : currentValue;
        });
    };
    
  9. min()
    Array.prototype.min = function() {
      var min = this[0];
      for(var i=1; i<this.length; i++) {
        if(min > this[i]) min = this[i];
      return min;
    };