乐趣区

最简单的继承和多重继承

A 继承 B 和 C,但是 B 和 C 没有改变

function C(c) {this.c = c}
C.prototype= {fnc() {console.log(this.c)}
}

function B(b) {this.b = b}
B.prototype= {fnb() {console.log(this.b)}
}

function A(a, b, c) {B.call(this, b)
  C.call(this, c)
  this.a = a
}
A.prototype = {fna(){console.log(this.a)}
}
Object.assign(A.prototype, B.prototype, C.prototype)

const a = new A(1, 2, 3)
console.log(a)

const b = new B(2)
console.log(b)

const c = new C(3)
console.log(c)
退出移动版