I am trying to figure out how to get a variable's name from code in javascript.
Ex:
var MYVAR = 3;//this is in file a.txt
abc(MYVAR);//this is in file a.txt
function abc(label) {//this is in file b.txt
alert(label); // this will print 3, but i want to print the name of the variable i.e., MYVAR
}
Required OUTPUT: "MYVAR"
File a.txt cannot be changed, only file b.txt can be changed
- anyone know this?.. is it possible in the current spec of the language???