> For the complete documentation index, see [llms.txt](https://strctr.gitbook.io/programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://strctr.gitbook.io/programming/01-languages/javascript/01-language/c-functions/c3-classes/06-mixins.md).

# 06. Mixins

One way of implementing a mixin in ES6 is to view it as a function whose input is a superclass and whose output is a subclass extending that superclass:

```javascript
const Storage = Sup => class extends Sup {
    save(database) { ··· }
};
const Validation = Sup => class extends Sup {
    validate(schema) { ··· }
};

// With these mixins, Employee is created like this:
class Employee extends Storage(Validation(Person)) { ··· }
```

Here, we profit from the operand of the extends clause not being a fixed identifier, but an arbitrary expression.
