Nodejs Array Max max()

Here you can find the source of max()

Method Source Code

Array.prototype.max = function(){
    var max = this[0];
    this.forEach(function(element, index, array){
        if(element > max){
            max = element;/* ww w  .ja  v a  2  s . c  om*/
        }
    })
    return max;
}

var arr1 = [3,6,9,1,5,0,11];

console.log(arr1.max());

Related

  1. max()
    Array.prototype.max = function() {
      return Math.max(...this);
    console.log([1,2,3,4,5].max());
    
  2. max()
    Array.prototype.max = function() { 
      return Math.max.apply(null, this) 
    
  3. max()
    Array.prototype.max = function(){
      return Math.max.apply({},this)
    
  4. max()
    var min = Math.min.apply(null, arr),
        max = Math.max.apply(null, arr);
    Array.prototype.max = function() {
      return Math.max.apply(null, this);
    };
    
  5. max()
    Array.prototype.max = function () {
      return Math.max.apply(Math, this);
    
  6. max()
    Array.prototype.max = function() {
      return Math.max.apply(null, this);
    };
    
  7. max()
    Array.prototype.max = function() {
      return Math.max.apply(Math, this);
    };