2015年12月18日
Last updated
Last updated
A.prototype.show=function ()
{
alert(this.abc);
};
for(var i in A.prototype)
{
B.prototype[i]=A.prototype[i];
}
B.prototype.fn=function(){
alert('abc');
}
var objA=new A();
var objB=new B();
objA.fn();//error.function A(){
this.abc=12;
}
function B(){
//这里的this指-->new B(),把A的this指向了B的this,本来给A加的属性,变成给B加的属性。
A.call(this);
}