87,901
社区成员
发帖
与我相关
我的任务
分享
function A(x){
this.x=x;
}
A.prototype.getx=function(){
return this.x;
}
function B(x,y){
this.y=y;
A.call(this,x);
}
B.prototype=new A();/*疑问*/
var b=new B(1,2);
alert(b.getx());
B.prototype=A.prototype;
function A(x){
this.x=x;
this.method = function(){
console.log('method');
}
}
A.prototype.getx=function(){
return this.x;
}
function B(x,y){
this.y=y;
// A.call(this,x);
}
// B.prototype=new A();/*疑问*/
B.prototype= A.prototype;
var b=new B(1,2);
console.log(b.getx());
console.log(b.method());