command to run javascript through string code example
Example 1: javascript execute string code
var theInstructions = "alert('Hello World'); var x = 100";
var F=new Function (theInstructions);
return(F());
Example 2: js execute string
var myString = "console.log('I am Batman')";
eval(myString);
//carefull ! This will execute the code, therefore
//be careful of where/how you got this string.