JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<fieldset>
<legend>Module Pattern</legend>
<p id ="foo"></p>
<p id ="fooo"></p>
<p id ="foooo"></p>
</fieldset>
</div>
JavaScript
//simple foo, just like the example in question but using module pattern
var foo = function() {
var that = {};
var privateVariabe = 100;
that.a = 7;
that.b = 6;
var privateMethod = function () {
return "private method - ";
}
that.c = function() {
return privateMethod() + (privateVariabe + that.a + that.b);
}
return that;
};
var fooObject = foo();
$('#foo').text('C Value: ' + fooObject.c());
fooObject.a = 3
fooObject.b = 7;
$('#fooo').text('C Value: ' + fooObject.c());
$('#foooo').text(typeof(fooObject.privateMethod));