// 扩展本地对象
//We create the method prototype for our arrays
//It only sums numeric elements
Array.prototype.sum = function(){
var len = this.length;
total = 0;
for(var i=0;i<len ;i++){
if(typeof this[i]!= 'number') continue;
total += this[i];
}
return total;
};
// 调用如下
var myArray = [1,2,3,'hola'];
myArray.sum();
Array.prototype.max = function(){
return Math.max.apply('',this);
}
// 其他学习资源1
[url]http://cymoft.blog.51cto.com/324099/63422[/url]
// 其他学习资源2
[url]http://www.jb51.net/article/11199.htm[/url]
// 其他学习资源3
[url]http://blog.youkuaiyun.com/chaojie2009/article/details/6719353[/url]