I am storing function body in string with function name.
function fnRandom(lim){
var data=[];
for(var i=0;i<lim;i++)
{
data=data.concat(Math.floor((Math.random() * 100) + 1));
}
return data;
}
After selecting the functionName from a drop down I use eval to execute function body.
JSON.stringify(eval(this.selectedFunction.body));
I want to pass 'lim' to this execution or can I use functionName as initiating point for execution somehow?
Function
constructor instead. – Skillernthis.selectedFunction
include any information about the parameters? If not, this will be difficult, because there's no way to know which undeclared variables in the body are parameters versus global variables. – Housetop