1.原型链
function a(){
this.a='aaaa';
}
function b(){
this.b='bbbb';
}
b.prototype=new a();
var obj = new b();
console.log(obj.a)
2.借用构造函数
function a(){
this.a='aaaa';
}
function b(){
a.call(this)
this.b='bbbb';
}
var obj = new b();
console.log(obj.a)
618

被折叠的 条评论
为什么被折叠?



