Want to avoid eval AND Function constructor
Trying hard to replace the eval without using Function constructor. Stumped. I am not a newbie but not an expert either.
jslint says this is evil; when I replaced it with a Function constructor, it said that was just a form of eval()!
evaluateEventScript: function(requestObject) {
var resultData;
resultData = eval(requestObject.script);
/开发者_JAVA百科/send resultData elsewhere...
}
Help??
Can't you simply pass a function object in your scenario? e.g
var c = function(){
...
}
var evaluateEventScript = function(requestObject) {
var resultData;
resultData = requestObject();
//send resultData elsewhere...
}
evaluateEventScript(c);
Or something in this form? this can work without eval or Function constructor. but it requires the requestObject to be a function object, and not a String.
精彩评论