Mixins add functionality to classes without inheritance. Copy methods from helper objects.
const TimestampMixin = {
getCreatedAt() {
return this.createdAt;
}
};
class User {
constructor() {
this.createdAt = new Date();
}
}
Object.assign(User.prototype, TimestampMixin);
Mixins help share code across unrelated classes.