JSFiddle - React, Tailwind, and code Playground

HTML

<script src="//greenish.github.io/js-objct/dist/objct.js"></script>

JavaScript

var a = {
	a : "A",					
	getValue:function(){ return this.a }
}

var b =  function(){};
b.prototype.b = "B";
b.prototype.getValue = function(){ return this.b }

var c = function (){	
	var c = "C"; // private property
	this.getC = function(){	return c } // privileged method
	this.getValue = function(){ return c } // privileged method
}

////////////////////////////////////////////////////////////////////////
// Factories

var factoryABC = objct(a,b,c);
var factoryCBA = objct(c,b,a);

var factoryAB = objct(a,b);

var factoryABc = objct(factoryAB, c); // same as factoryABC

console.log("factoryABc === factoryABC", factoryABc(), factoryABC());

////////////////////////////////////////////////////////////////////////
// Basic inheritance
var instanceABC = factoryABC(); // 

console.log('instanceABC.a === "A"',instanceABC.a === "A");
console.log('instanceABC.b === "B"', instanceABC.b === "B");
console.log('instanceABC.c === undefined', instanceABC.c === undefined);
console.log('instanceABC.getC() === "C"', instanceABC.getC() === "C"); // privileged method has access to c

////////////////////////////////////////////////////////////////////////
// Existing properties are overwritten by later added modules 

var instanceABC = factoryABC()
var instanceCBA = factoryCBA();

console.log('instanceABC.getValue() === "C"',instanceABC.getValue() === "C");
console.log('instanceCBA.getValue() === "A"',instanceCBA.getValue() === "A");

////////////////////////////////////////////////////////////////////////
// Instances are separate

var instance1 = factoryABC()
var instance2 = factoryABC()

instance2.a = "X"; // redefine a in instance2

console.log('instance1.a === "A"',instance1.a === "A");  // instance 1 is not affected
console.log('instance2.a === "X"',instance2.a === "X");