function A(name){ this.name = name; } A.prototype.say = function(){ console.log(this.name); } let a = new A('x'); a.say(); function B(name, sex){ A.call(this, name) this.sex = sex; } Object.setPrototypeOf(B, A); B.prototype.say1 = function(){ console.log(this.sex); } B.constructor = B; let b = new B('x', 'y'); b.say(); b.say1(); console.log(b);