首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js prototype运用大全详解

2012-11-23 
js prototype使用大全详解// 扩展本地对象//We create the method prototype for our arrays //It only su

js prototype使用大全详解

// 扩展本地对象//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
http://cymoft.blog.51cto.com/324099/63422

// 其他学习资源2
http://www.jb51.net/article/11199.htm

// 其他学习资源3
http://blog.csdn.net/chaojie2009/article/details/6719353

热点排行