/ Published in: JavaScript
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Array.prototype.foreach = function(callback) { for(var k=0; k<this.length; k++) { callback(k, this[k]); } }
URL: http://www.naden.de/blog/javascript-foreach