我正在做一个原型继承方法测试..我得到一个错误,即使我将实例复制到我现有的对象之后......
这里有什么问题..
我的测试:
var human = function(name){
this.name = name;
}
human.prototype.say = function(){
alert(this.name);
}
var male = function(gender){
this.gender = gender;
}
male.prototype.Gender = function(){
alert(this.gender);
}
var inst1 = new human('nw louies');
inst1.say();
var inst2 = new male("male");
inst2.prototype = new human("sa loues philippe"); //i am copying the instance of human
inst2.Gender();
inst2.say(); // throw the error as "undefined"
这里有什么问题..有人帮我理解我的错误吗?