【发布时间】:2014-06-18 08:54:08
【问题描述】:
我正在使用对象 A 和 A.B 与
A.myB = A.B;
我有一个继承的A1 和A1.B,其中A1.B 继承自A.B
和
A1.myB = A1.B;
实现这一点的代码如下所示:
A = function() {
this.myB = this.createB();
};
...
A.prototype.createB = function() {
return new A.B();
};
然后在继承 A 我需要更改 .createB:
A1.prototype.createB = function() {
return new A1.B1();
};
我想我忽略了一些东西 - 有没有更直接的方法来设置它,而无需更改 createB?
【问题讨论】:
标签: javascript inheritance constructor prototype