Javascript Array forEach(cb)

Description

Javascript Array forEach(cb)


'use strict';/*from   w w  w  .j av a2 s  .  c  om*/

Array.prototype.forEach = function(cb) {
  for(let i = 0 ; i < this.length ; i++) {
    cb(this[i]);
  }
};

Javascript Array forEach(cb)

Array.prototype.forEach = function(cb){
  for(var k in this) cb(this[k]);
};



PreviousNext

Related