O'Reilly logo

Ember.js Web Development with Ember CLI by Suchit Puri

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reuse via mixins

As we saw in the above examples, JavaScript objects can inherit properties from other objects. The inherited object can also inherit properties and behavior from other objects, thus forming an inheritance chain. While sometimes it makes sense to represent the object hierarchy in terms of their natural order, but a lot of other times it also becomes messy and unmanageable to handle long inheritance chains. Thankfully, when it comes to alternatives for function reuse, JavaScript makes it possible to implement the mixin reuse design pattern.

In computer science, a mixin is a class, which contains the behavior for a particular type (shape, color, person). Mixins are supposed to contain the behavior, or verbs, rather than the properties, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required