示例:
var something = "some text";
test(something);
function test(param){
printParamName(param);
}
//console
"something"
我想在控制台中打印:“某事” 我传递给测试函数的变量的变量名。
更新
该变量位于文件中,该函数位于另一个文件中......
解释原因是复杂的....但我想避免硬编码测试函数中另一个函数的参数。
文件1:
var something = "some text";
test(something);
file2的:
function test(param){
var something = anotherFunctionCall('something'); //I want to put here nameof var something.
var somethingElse = anotherFunctionCall('somethingElse');
}
file3的:
another component "anotherFunctionCall"
我想避免使用这个硬编码的名字。我想通过名字抛出那个功能。