Javascript Array iterate(func, args)
Array.prototype.iterate = function(func, args) { if (!(args instanceof Array)) { args = [args];/*from w w w. ja v a 2 s.co m*/ } var l = this.length, a = []; for (var i=0; i<l; i++) { a.push(func.apply(this[i], args)); } return a; }