Posted By

iamarcel on 11/04/11


javascript array index Value callback each

Versions (?)


 / Published in: JavaScript

There you go, a simple implementation of a method to loop trough your JavaScript arrays. I am by no means an expert of Javascript, but I tried to make it as fast and short (in terms of amount of characters ;) ) as possible.

  1. /* Array.each( callback(index, value) );
  2. / You can also refer to "this" inside your function, which will refer to your array. */
  3. Array.prototype.each=function(c){var a=this,l=a.length,i;for(i=0;i<l;i++){,i,a[i]);}};

Report this snippet  

You need to login to post a comment.