I´ve searched for a solution all afternoon. First I was enthusiastic but now I´m just annoid.
Maybe you can help me. Maybe there is no solution.
If you want to get the “name” of a variable you simply can use Object.keys().
const myFirstName = 'John';
console.log(myFirstName);
console.log(Object.keys({myFirstName})[0]);
BUT if you want to write a function and use the variable as the parameter,
this solution does not work anymore.
function hfr_log(variable)
{
let tmp_variable = variable;
let tmp_s_variable_name = Object.keys({variable})[0];
let tmp_variable_content = variable;
console.log(`tmp_variable = '${tmp_variable}'`);
console.log(`tmp_s_variable_name = '${tmp_s_variable_name}'`);
console.log(`tmp_variable_content = ${tmp_variable_content}`);
}
I’ve tried several approaches on how to pass the variable, but I’m running out of ideas.
Is it even possible?
Sorry for the beginner question, but I’m afraid I’m a beginner. :/
In any case, thank you very much for your time and your suggestions! 🙂