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

javascript定义种或者对象

2012-11-01 
javascript定义类或者对象1.工厂方式? ?function Obj(sColor, iSize){this.color sColorthis.size iS

javascript定义类或者对象

1.工厂方式

?

?

function Obj(sColor, iSize){     this.color = sColor;     this.size = iSize;     this.drivers = new Array("zhang","wang");          if(typeof Obj._initialized == "undefined"){          Obj.prototype.tellSize = function() {              alert(this.size);           };           Obj._initialized = true;      }}var oObj1 = new Obj("red",14);var oObj2 = new Obj("white",10);oObj1.drivers.push("li");alert(oObj1.drivers);     //output "zhang wang li"alert(oObj2.drivers);     //output "zhang wang"

?

?

??

热点排行
Bad Request.