在JavaScript中,一个函数是否可以返回它自己的函数调用作为一个字符串?
function getOwnFunctionCall(){
//return the function call as a string, based on the parameters that are given to the function.
}
我希望这个函数可以将自己的函数调用以字符串形式返回(如果可能的话):
var theString = getOwnFunctionCall(5, "3", /(a|b|c)/);
//This function call should simply return the string "getOwnFunctionCall(5, \"3\", "\/(a|b|c)\/")".
eval
语句中特定函数被评估的方法,这是解决该问题的一个潜在解决方案。 - Anderson Green