/ 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.
Expand |
Embed | Plain Text
/* Array.each( callback(index, value) ); / You can also refer to "this" inside your function, which will refer to your array. */ Array.prototype.each=function(c){var a=this,l=a.length,i;for(i=0;i<l;i++){c.call(a,i,a[i]);}};
You need to login to post a comment.
