我的情況下,(爲什麼 「測試1」 沒有出現在警報窗口):爲什麼JavaScript原型不工作在這種情況下
var Parent=function(){
this.test1= function(){
alert("test1");
}
}
var Child=function(){
this.prototype=new Parent();
}
var test=new Child();
test.test1();
http://jsfiddle.net/c3sUM/2/(相同的代碼在網上試試)
感謝
請使用函數聲明而不是函數表達式。這裏使用表達式沒有任何好處。 – RobG