Mixin Pattern Practice
Ruby likes it, so IT MUST BE GOOD!!!1!!11
JavaScript
var asCircle = function() {
this.area = function() {
return Math.PI * this.radius * this.radius;
};
this.grow = function() {
this.radius++;
};
this.shrink = function() {
this.radius--;
};
return this;
};
var Circle = function(radius) {
this.radius = radius;
};
asCircle.call(Circle.prototype);
var circle1 = new Circle(5);
console.log(circle1.area()); //78.54