Array.prototype.each = function(fn) { for(var i in this) { this[i] = fn(this[i]); } return this } alert([1,2,3].each(function (a) { return a*a }));