1

例子:

var something = "some text";

test(something);

function test(param){
printParamName(param);
}

//console
"something"

我想在控制台中打印:“某物”我传递给测试函数调用的变量的名称。

更新

变量在一个文件中,函数在另一个文件中...

解释原因很复杂......但我想避免硬编码另一个函数的参数,例如在测试函数中。

文件1:

var something = "some text";

test(something);

文件2:

function test(param){
    var something = anotherFunctionCall('something'); //I want to put here nameof var something.
    var somethingElse = anotherFunctionCall('somethingElse');
}

文件3:

another component "anotherFunctionCall"

我想避免那个硬编码的名字。我想通过名称抛出该函数。

4

0 回答 0