// Prototype Factory mode function Extend (target, Origin) { target.prototype = the Object.create (origin.prototype); // This method creates an object, modify the parent class and subclass Prototype Prototype independently Object.defineProperty (target .prototype, "constructor" , { value: target, Enumerable: to false }) }
// object factory mode function the User (Age, name) { this.age = Age; this.name = name; } function Member (Age, name ) { the let instance the Object.create = (User.prototype); User.call (instance, Age, name); instance.pri = function () { the console.log ([Age, name]); } return instance; } var queen = member(11, 'Tom');
// multiple inheritance accomplished by mixin the let ADMIN = { prtadmin () { return "ADMIN" ; } } the let User = { the __proto__: ADMIN, // internal mixin inheritance prtuser () { the console.log (super.prtadmin () + "User"); // Super .__ proto__ the this keyword = } }; // the three ways in the method of adding function prototypes // Fun.prototype.user = user.prtuser; // Fun.prototype.admin = ADMIN .prtadmin; the method may be a method of adding rename // Object.assign (Fun.prototype, ADMIN, User); using the method changes the original object Object.assign @ Fun.prototype = Object.assign(Fun.prototype, admin, user); function Fun() { } let fun = new Fun();