JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<p><strong>Console says:</strong></p>
<code id="console"></code>
</div>
JavaScript
// Private variables in MooTools
// var console = console || { log: function() { document.id('console').innerHTML += Array.from(arguments).toString() + "<br />"; }}
var Private = function (){
var secret = "cookies";
return new (new Class({
initialize: function(options) {
console.log('class options are: ', options);
console.log(this.method());
},
method: function(){
return 'method!';
},
getSecret: function(){
return secret;
},
setSecret: function(content){
secret = content;
}
}))(Array.from(arguments));
};
// Instance 1
var test1 = new Private('option 1a', 'option 1b');
console.log( test1.getSecret() );
test1.setSecret('bacon');
console.log( test1.getSecret() );
// Instance 2
var test2 = new Private('option 2');
console.log( test2.getSecret() );