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

js prototype原形对象用处

2012-09-04 
js prototype原型对象用处Array.prototype.pushEx function(obj){var a truefor (var i 0 i thi

js prototype原型对象用处

Array.prototype.pushEx = function(obj){  var a = true;  for (var i = 0; i < this.length; i++) {    if (this[i]== obj) {       this[i] = obj;       a =false;       break;    }  }  if(a){    this.push(obj);   }  return this.length;}var test1 = new Array();test1.pushEx("bb");test1.pushEx("bb");test1.pushEx("dd");alert(test1) //bb,dd

热点排行