js 继承为什么运行的时候总是弹出undefined
关于js的继承,求大侠指点,为什么总是unfined。代码如下functionAnimal(){};Animal.prototype.species="动物";funct...
关于js的继承,求大侠指点,为什么总是unfined。代码如下
function Animal(){};
Animal.prototype.species = "动物";
function dog(name,color){
/ar F = function(){};
/* F.prototype = Animal.prototype; */
this.name=name;
this.color=color;
dog.prototype =new Animal()
dog.prototype.constructor= dog;
// dog.prototype=new Animal();
// dog.prototype.constructor=dog();
};
var dog1=new dog("大狗","黑色");
alert(dog1.species); 展开
function Animal(){};
Animal.prototype.species = "动物";
function dog(name,color){
/ar F = function(){};
/* F.prototype = Animal.prototype; */
this.name=name;
this.color=color;
dog.prototype =new Animal()
dog.prototype.constructor= dog;
// dog.prototype=new Animal();
// dog.prototype.constructor=dog();
};
var dog1=new dog("大狗","黑色");
alert(dog1.species); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询