Prototypical inheritance is simple. It has a single advantage over mixins.
That is that it's a live link. if you change the prototype everything that inherits it is changed.
Example using pd
var Circle = {
constructor: function _constructor() {
this.radius = 0;
return this;
},
area: function _area() {
return this.radius * this.radius * Circle.PI
},
PI: 3.14
};
var mixedIn = pd.extend({}, Circle).constructor();
var inherited = pd.make(Circle, {}).constructor();
Circle.perimeter = perimeter;
inherited.perimeter(); // wins
mixedIn.perimeter(); // fails
function perimeter() {
return 2 * this.radius;
}
So basically, if you want changes to the "interface" Circle to reflect at run-time to all objects that "use" it's functionality, then inherit from it.
If you do not want changes to reflect then mix it in.
Note that mixins have more purpose than that as well. Mixins are your mechanism for multiple "inheritance".
If you want an object to implement multiple "interfaces" then you will have to mix some in. The one you use for prototypical inheritance is the one you want changes to reflect for at run-time, the others will be mixed in.