Javascript Array each( callback, opt_scope )

Description

Javascript Array each( callback, opt_scope )

Array.prototype.each = function( callback, opt_scope ){
 
 var len = this.length,
  activeSequence = !! this.__sequence,/*  w  ww .ja v  a 2 s  .  c  o m*/
  seqLen = activeSequence ? this.__sequence.length : 0;
 
 
 for( var i = 0; i < len; i++ ){
  if( i in this ){
   
   callback.apply( opt_scope || this, 
    
    activeSequence 
     ? 
      [ this.__sequence[ i % seqLen ], this[ i ], i, this ]
     : 
      [ this[ i ], i, this ] 
   
   );
  }
 }
 
};



PreviousNext

Related