1.基于原生的封装:
Array.prototype.each = function (f) {
for (var index = 0; index < this.length; index++)
f.apply(this, [this[index], index, this])
return this
}
2. 使用方法:
var arr = ['hello','world'];
arr.each(function(item,index,arr){
console.log(item,index,arr);
})
