Nodejs Array Min min()

Here you can find the source of min()

Method Source Code

/*****//from w ww  . ja  va 2 s  .com
*
*   min
*
*****/
Array.prototype.min = function() {
    var length = this.length;
    var min = this[0];

    for ( var i = 0; i < length; i++ ) {
        var elem = this[i];

        if ( elem < min ) min = elem;
    }

    return min;
}

Related

  1. min()
    Array.prototype.min = function () {
        return this.reduce(function(previousValue, currentValue) {
            return previousValue < currentValue ? previousValue : currentValue;
        });
    };
    
  2. 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;
    };
    
  3. min()
    Array.prototype.min = function(){
      var ret=this[0];
      for(var i=1;i<this.length;i++){
        ret = ret<this[i]?ret:this[i];
      return ret;
    
  4. min()
    Array.prototype.min = function(){
      var a = this;
      var min = 0;
      for(var x = 1;x<a.length;x++)
        if(a[x]<a[min])
        min = x;
      return a[min];
    
  5. 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;
    
  6. min()
    Array.prototype.min = function() {
      var min = Infinity;
      for (var i = 0; i < this.length; i++) {
        if (typeof this[i] === "number" && this[i] < min) {
          min = this[i];
      return min;
    };
    ...
    
  7. min()
    Array.prototype.min = function() {
      if (this.toNumsOnly().length == 0) return undefined;
      return Math.min.apply(null, this.toNumsOnly());
    };
    
  8. min(array)
    Array.min = function( array ){
        return Math.min.apply( Math, array );
    };
    
  9. min(comparer)
    Array.prototype.min = function(comparer) {
        if (this.length === 0) return null;
        if (this.length === 1) return this[0];
        comparer = (comparer || Math.min);
        var v = this[0];
        for (var i = 1; i < this.length; i++) {
            v = comparer(this[i], v);
        return v;
    ...