您好!欢迎来到聚码网

聚码网

热门搜索: 相亲小程序    搭子源码    直播系统自有商城   
  • 关于继承的问题
  • 聚码交流
  • 0 1
  • yhuxAvNbtxUM
    0000-00-00 00:00:00
  • 回帖
functionextend(Child,Parent){varF=function(){};F.prototype=Parent.prototype;Child.prototype=newF();Child.prototype.constructor=Child;Child.uber=Parent.prototype;}functionShape(){}Shape.prototype.name='Shape';Shape.prototype.toString=function(){returnthis.constructor.uber?this.constructor.uber.toString()+','+this.name:this.name;};functionTwoDShape(){}extend(TwoDShape,Shape);TwoDShape.prototype.name='2Dshape';functionTriangle(side,height){this.side=side;this.height=height;}varF=function(){};extend(Triangle,TwoDShape);Triangle.prototype.name='Triangle';Triangle.prototype.getArea=function(){returnthis.side*this.height/2;};varShape=function(){};varTwoDShape=function(){};Shape.prototype.name='shape';Shape.prototype.toString=function(){returnthis.uber?this.uber.toString()+','+this.name:this.name;};extend(TwoDShape,Shape);vartd=newTwoDShape();td.name;//"shape"1.为什么说name属性既不会是TwoDShape()实例的属性,也不会成为其原型对象的属性,但是子对象依然可以通过继承方式来访问该属性?
最近热帖
近期热议
联系我们
Q Q:317563994
电话:400-000-000
邮箱:317563994@qq.com
时间:09:00 - 17:00