Google News
logo
TypeScript - Interview Questions
What are Mixins?
Combining simpler partial classes is a popular approach of constructing classes from reusable components. For languages like Scala, you may be familiar with the concept of mixins or characteristics.
 
To extend a base class, the design relies on generics and class inheritance. The finest mixin support in TypeScript is provided through the class expression pattern.
 
We have a class where mixins are applied on top of it.
class Sprite {
 name = "";
 x = 0;
 y = 0;
 constructor(name: string) {
   this.name = name;
 }
}
Advertisement