123456789101112131415161718192021222324// 父类function Parent() { this.sayHello = function () { console.log("Hello"); }}Parent.prototype.a = "我是父类prototype上的属性";// 子类function Child() { Parent.call(this)}Child.prototype = new Parent()// 创建两个Child实例var child1 = new Child();var child2 = new Child();console.log(child1.sayHello === child2.sayHello);// falsevar parentObj = new Parent();console.log(parentObj.a);//我是父类prototype上的属性console.log(child1.a)//我是父类prototype上的属性 优点: 原型属性不会被共享。 可以继承父类的原型链上的属性和方法。缺点: 调用了 2 次 Parent()。 它在 child 的 prototype 上添加了父类的属性和方法。