缺点:前面两个问题解决,但父类构造函数会多执行一次
function Parent3() { this.name = 'parent3' this.play = [1, 2, 3] } function Child3() { Parent3.call(this) this.type = 'child3' } Child3.prototype = new Parent3() const c31 = new Child3() const c32 = new Child3() c31.play.push(4) console.log(c31.play) // [1, 2, 3, 4] console.log(c32.play) // [1, 2, 3]