Nodejs Array Each each(action)

Here you can find the source of each(action)

Method Source Code

Array.prototype.each = function(action) {

    for (var i = 0, l = this.length; i < l; ++i) {
    /*from ww w . j av a2s. c  o  m*/
        action(this[i], i);
   }
};

Related

  1. each( func )
    Array.prototype.each = function( func ) {
      for( var i=0; i<this.length; i++ ) {
        func( this[i], i );
      return this;
    };
    
  2. each()
    Array.prototype.each = Array.prototype.forEach;
    Object.prototype.eachKey = function (cb) {
      var k = Object.keys(this);
      for (var i = 0; i < k.length; i++)
        cb(k[i], this[k[i]]);
    };
    var times = function (n, cb) {
      for (var i = 0; i < n; i++) cb(n);
    };
    ...
    
  3. each()
    Array.prototype.each = function () {
      this.forEach.apply( this, arguments );
      return this;
    };
    
  4. each(action)
    Array.prototype.each = function(action) {
      var args = getArgs(1,arguments);
      var arr = this;
       for (var i = 0, l = arr.length; i < l; ++i) {
            action.apply(this,[arr[i],i].concat(args));
    };
    
  5. each(action)
    Array.prototype.each = function(action){
        for(var i = 0; i< this.length; i++){
            action(this[i], i);
    };
    
  6. each(action)
    Array.prototype.each = function (action) {
      this.map(function(el){action(el);});
      return this;
    };
    
  7. each(block)
    Array.prototype.each = function(block){
      for(var i=0;i<this.length;i++)
         block(this[i])
    
  8. each(callback)
    Array.prototype.each = function(callback){
      for(var i = 0; i < this.length; i++){
        callback(this[i]);
    
  9. each(callback)
    Array.prototype.each = function(callback) {
      for (var i = 0;i < this.length;i++) {
        callback(this[i], i);
    };