JSFiddle - React, Tailwind, and code Playground
JavaScript
var object = {
flapWings : function(count) { alert("I am flapping my wings "+count+" times"); },
kick : function(count) { alert("I am kicking my legs "+count+" times"); },
functionmap : {
"bird" : { label : "Bird", action : this.flapWings },
"horse" : { label : "Horse", action : this.kick }
},
doAction : function (type, count) {
alert("I am a "+this.functionmap[type].label);
this.functionmap[type].action(count);
}
};
object.doAction("horse", 5);