Mixins
Explore the concept of mixins in ES6 and how Object.assign replaces traditional methods from libraries like UnderscoreJs to compose objects dynamically. Understand why mixins provide a flexible alternative to class inheritance, enabling efficient combination of features without creating deep hierarchies. This lesson helps you apply mixins to build modular and maintainable JavaScript objects.
We'll cover the following...
Heated debates of composition over inheritance made mixins appear to be the winner construct for composing objects. Therefore, libraries such as UnderscoreJs and LoDash created support for this construct with their methods _.extend or _.mixin.
In ES6, Object.assign does the same thing as _.extend or _.mixin.
Why are mixins important?
They are important because the alternative of establishing a class hierarchy using ...