Inheritance in Javascript (Mixin and Delegation)
Inheritance in Javascript sucks. The design pattern of classical inheritance are ugly and convoluted. The only inheritance I feel like you should do is prototype chaining. Which is limited to primitive that aren't reference (array and object are reference). Which leads to the question how do we solve the inheritance problem? If you read and study design patterns you should prefer composition over inheritance when ever possible. Inheritance is actually very unnatural and use with caution. So with that there are solutions: Mixins In order to understand the Mixin design pattern you have to understand delegation (w.r.t. .call() function). Here's some links: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/call http://javascriptweblog.wordpress.com/2010/12/22/delegation-vs-inheritance-in-javascript/ From there (mixin): http://javascriptweblog.wordpress.com/2011/05/31/a-fresh-look-at-javascript-mixins/ https://speakerdeck.com/anguscroll/how-we-learned-to-stop-worrying-and-love-javascript https://speakerdeck.com/anguscroll/the-why-and-how-of-mixins-in-flight














