Javascript Array each(f)

Description

Javascript Array each(f)


Array.prototype.each = function(f) {
  for (var i=0; i<this.length; i++) {
    f(this[i])//from   w  w w  .  j a va  2 s .com
  }
}

Array.prototype.each_with_index = function (f) {
  for (var i=0; i<this.length; i++) {
    f(this[i], i)
  }
}

Javascript Array each(f)

Array.prototype.each = function(f) {
    var res;/*from  w  w w. ja  v  a2  s . com*/
    for(var i = 0; i < this.length; i++) {
        res = f.call(i, this[i]);
    }
    return res;
}

Javascript Array each(f)

Array.prototype.each = function(f) {
 for(var i = 0, len = this.length; i < len; i++) {
  f(this[i]);/*  www  .ja  v  a2s . c o  m*/
 }
};

Javascript Array each(f)

Array.prototype.each = function(f) {
 for(var i = 0; i < this.length; i++)
  f(this[i], i);//from   w  w  w.  ja  v a2  s. c o  m
};



PreviousNext

Related