I have a function that takes 2 inputs, the variable name as a string and the variable itself - it prints both via console.
var variable1 = ["entry1","entry2"];
function logthis(input1, input2){
console.log(input1+ "\n " + input2)
}
logthis("variable1", variable1) ;
I want to be able to use it as logthis(variable1);
and get the same result.
How can I reference the variable name (as a string) and not its contents?
eg, console.log(input2.name) will not work
Something like the C+ equivalent of "nameOf(variable1)"