['test',false,12].each( function() { alert(this); })
Array.prototype.each = function(fn) { for(var el in this) { fn(this[el]); } }
Array.prototype.each = function(fn) { for(var el in this) { fn.call(this[el]); } }
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 }));
Array.prototype.each = function(fn) { for(var el in this) { if(Array.prototype.each != this[el]) fn.call(this[el]); } }
Array.prototype.each = function(fn) { for (var i=0; i<this.length; i++) {this[i] = fn.call(this, this[i], i);} return this } alert([1,2,3].each(function (a) { return a*a })); ['test',false,12].each( function(el, i) { alert([el,i]); return el })