Javascript Array eachWithIndex(callback)
Array.prototype.eachWithIndex = function(callback) { for(var i = 0; i < this.length; i++) { callback(this[i], i);/*from www . java2 s . co m*/ } }