プロトタイプ継承メソッドのテストを行っています.インスタンスを既存のオブジェクトにコピーした後でもエラーが発生します...
ここで何が悪い..
私のテスト:
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"
ここで何が問題なのですか..誰かが私の間違いを理解するのを手伝ってくれますか?