JSFiddle - React, Tailwind, and code Playground

JavaScript

// a.callThis is the function that will be called using var string
var a = {
  callThis:
     function (ok, param1, param2) {
			alert(ok + "|" + param1 + "|" + param2);
		}
}

// Below is from http://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string 
function executeFunctionByName(functionName, context /*, args */) {
  var args = [].slice.call(arguments).splice(2);
  var namespaces = functionName.split(".");
  var func = namespaces.pop();
  for(var i = 0; i < namespaces.length; i++) {
    context = context[namespaces[i]];
  }
  return context[func].apply(context, args);
}

// try call a.callThis by var string
var fn = 'a.callThis';
executeFunctionByName(fn, window, true, 'param1', 'param2');