传递给函数后确定变量的原始名称 [英] Determine original name of variable after its passed to a function
本文介绍了传递给函数后确定变量的原始名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一种感觉,这可能是不可能的,但我想确定一个已经传递给javascript中的函数的变量的原始变量名。我不知道如何更好地解释它,所以看看这个例子是否有意义。
I've got a feeling this might not be possible, but I would like to determine the original variable name of a variable which has been passed to a function in javascript. I don't know how to explain it any better than that, so see if this example makes sense.
function getVariableName(unknownVariable){
return unknownVariable.originalName;
}
getVariableName(foo); //returns string "foo";
getVariableName(bar); //returns string "bar";
这是我正在研究的jquery插件,我希望能够显示传递给调试函数的变量的名称。
This is for a jquery plugin i'm working on, and i would like to be able to display the name of the variable which is passed to a "debug" function.
推荐答案
你是对的,这是非常不可能的以任何理智的方式,因为只有值传递给函数。
You're right, this is very much impossible in any sane way, since only the value gets passed into the function.
这篇关于传递给函数后确定变量的原始名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文