Return to Snippet

Revision: 17328
at September 1, 2009 08:35 by naden


Initial Code
Array.prototype.foreach = function(callback) {
  for(var k=0; k<this.length; k++) {
    callback(k, this[k]);
  }
}

Initial URL
http://www.naden.de/blog/javascript-foreach

Initial Description
I saw a lot of bad javascritp foreach examples ... so here is the best solution. See the link (german) for another snippet to iterate over object properties via foreach.

Initial Title
Javascritp foreach

Initial Tags
javascript

Initial Language
JavaScript