We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
function object (o) { function F () {} F.prototype = o; return new F(); } function inheritPrototype (Sub, Super) { var proto = object(Super.prototype); proto.constructor = Sub; Sub.prototype = proto; } function Super () { } function Sub () { Super.call(this); } inheritPrototype(Sub, Super);
下面我们借用 原型式借用构造组合继承 来实现多重继承
原型式借用构造组合继承
function A() { this.class = 'A'; } A.prototype.sayClass = () => { console.log('debug-sayClass', this.class); } function B () { this.name = 'B'; } B.prototype.sayName = () => { console.log('debug-sayName', this.name); } function C () { A.apply(this); B.apply(this) this.type = 'C'; } C.prototype = Object.create(Object.assign({}, A.prototype, B.prototype)); var c = new C(); c.sayClass(); c.sayName();
The text was updated successfully, but these errors were encountered:
No branches or pull requests
js 中多重继承的实现
比较好的继承方式
原型式借用构造组合继承
下面我们借用
原型式借用构造组合继承
来实现多重继承参考
The text was updated successfully, but these errors were encountered: