This question already has an answer here:
- JavaScript: Get Argument Value and NAME of Passed Variable [duplicate] 7 answers
- Determine original name of variable after its passed to a function 3 answers
Consider
function woei(someArg) { }
function caller() {
var x = "value";
woei(x);
}
how to get the name of the variable from the called function? In code:
function woei(someArg) {
// magic to find out the name of the function argument variable
console.debug(nameOfArgument);
}
prints x
, not "value" (actual value of the argument) nor "someArg" parameter name in the function itself.
Aucun commentaire:
Enregistrer un commentaire