JSFiddle - React, Tailwind, and code Playground

by Jon-Carlos Rivera

JavaScript

// Simple compose function (only takes two arguments, most compose functions are variadic)
function compose (a, b) {
    return function(){
        return a.call(this, b.apply(this, arguments));
    };
}

var asElectronic = function (obj) {
  obj.voltage = '220v';
  return obj;
};

// All sound reproducer are a eletronic
var asSoundReproducer = compose(function (obj) {
    obj.watts = 60;
    return obj;
  },
  asElectronic);

var MicroSystem = function(){
  this.cd = false;
  this.mp3 = true;
};

var TV = function(){
  this.pol = 42;
  this.hdmi = true
};


// Micro System is a sound reproducer
asSoundReproducer(MicroSystem.prototype);

// TV is a sound reproducer
asSoundReproducer(TV.prototype);

var myTV = new TV();

console.log(myTV);