mercredi 8 avril 2015

How to get caller argument name? [duplicate]


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