From 190e2f5ac39ee105d3c28b173738c4cafc0cc21a Mon Sep 17 00:00:00 2001 From: nakhodkin <14351638+nakhodkin@users.noreply.github.com> Date: Sun, 28 Jan 2024 23:56:45 +0200 Subject: [PATCH] Clarification on a matter of using multiple mixins --- 1-js/09-classes/07-mixins/article.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/1-js/09-classes/07-mixins/article.md b/1-js/09-classes/07-mixins/article.md index 526b832efa..dbe2b64b81 100644 --- a/1-js/09-classes/07-mixins/article.md +++ b/1-js/09-classes/07-mixins/article.md @@ -105,6 +105,8 @@ That's because methods `sayHi` and `sayBye` were initially created in `sayHiMixi As `super` looks for parent methods in `[[HomeObject]].[[Prototype]]`, that means it searches `sayHiMixin.[[Prototype]]`. +It is worth noting that it would be illegal to write `new User("Dude").say()` as `say` that comes from `sayMixin` doesn't reside in a prototype chain of the `User` class. For this to work though, you should copy methods from each mixin separately like so: `Object.assign(User.prototype, sayMixin, sayHiMixin);` + ## EventMixin Now let's make a mixin for real life.