Javascript Array forEach(iteratee, context)

Description

Javascript Array forEach(iteratee, context)



Array.prototype.forEach = function(iteratee, context) {
 if (typeof iteratee !== "function") {
  throw new TypeError(iteratee + ' is not a function')
 }
 for (let i = 0, len = this.length; i < len; i++) {
  if(iteratee.call(context, this[i], i, this) === false){
   break;// w ww.  ja  v  a  2s  . c om
  }
 }
}



PreviousNext

Related