【发布时间】:2015-07-16 02:57:21
【问题描述】:
有没有办法在javascript中获取方法名称和传入参数?
让
function say(param){
alert(param);
}
所以当say方法被调用时,
say("helloworld")
我会得到方法:'say' 和参数:{'helloworld'}
【问题讨论】:
-
用html代码详细解释
-
Use Function.caller 获取调用函数。将该函数转换为 .toString()。然后parse the string to get the function name 和use a regex to get the argument names。至于参数的值,它们列在一个名为“参数”的特殊对象中 (MDN link)。
标签: javascript jquery