缺点:构造函数变成了父类
这里让将父类原型对象直接给到子类,父类构造函数只执行一次,而且父类属性和方法均能访问,但是子类实例的构造函数是 Parent4,显然这是不对的,应该是 Child4
function Parent4() { this.name = 'parent4' this.play = [1, 2, 3] } function Child4() { Parent4.call(this) this.type = 'child4' } Child4.prototype = Parent4.prototype var c41 = new Child4() console.log(c41)