You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letsayMixin={say(phrase){alert(phrase);}};letsayHiMixin={__proto__: sayMixin,// (or we could use Object.create to set the prototype here) !!! this may be wrongsayHi(){// call parent methodsuper.say(`Hello ${this.name}`);// (*)},sayBye(){super.say(`Bye ${this.name}`);// (*)}};classUser{constructor(name){this.name=name;}}// copy the methodsObject.assign(User.prototype,sayHiMixin);// now User can say hinewUser("Dude").sayHi();// Hello Dude!
Object.create can set proto of sayHiMixin, but its method can be only function properties by
Object.create can set proto of sayHiMixin, but its method can be only function properties by
or
Calling super later will cause an error becasue both in these way there;s no [[HomeObject]], super keyword unexpected here.
The text was updated successfully, but these errors were encountered: