JSFiddle - React, Tailwind, and code Playground

by Michael Prosser

JavaScript

var execute = function(obj,func,code){
		
		// get the function name 
    
    var f = { f: "function(){ " + code + " }"};
    
    obj[func] = f.f;

		if (typeof obj[func] === "function"){ 

			return obj[func](param);

		} else {
			
			console.log("THE FUNCTION " + func + " DOES NOT EXIST!");
			
		}

		console.log("execution mismatch!");

	}
  
  var data = Array();
  data['onBeforeIClickThisButton'] = function(p){
  
  	alert("INITIAL VALUE!");
  
  }
  
  var d = JSON.parse("{ \"f\": \"function(){ alert('I did it'); }\" }");
  
  console.log(d);
  console.log(d.f);
  d.f();
  
  //execute(data,'onBeforeIClickThisButton',code);