function Polygon(sides){ if(this instanceof Polygon){ this.sides=sides; this.getArea=function(){ return 0; } }else{ return new Polygon(sides); } } function Rectangle(wifth,height){ Polygon.call(this,2); this.width=this.width; this.height=height; this.getArea=function(){ return this.width * this.height; }; } var rect=new Rectangle(5,10); alert(rect.sides); //undefined这段代码是js高程三中P598-599的一个例子我想问的是为什么alert的是undefined呢?
添加回答
举报
0/150
提交
取消