JSFiddle - React, Tailwind, and code Playground
by darcyclarke
JavaScript
/// hawt
var closure = function(){
// some random function
var foo = function(bar){
console.log(bar);
};
// heavy lifting function
this.run = function(fn,args){
if(typeof this[fn] === 'function'){
this[fn].call(this,args);
} else {
return false;
}
};
};
// create an instance of the closure
var test = new closure();
// execute private function [ function_name, function_arguments ]
test.run('foo',['log this message']);
test.foo('yo');