I'm trying to log variable name in JavaScript with its value using a function with the following code...
var x = 5;
function get(v) {
console.log(Object.keys({v})[0] + " = " + v);
}
get(x); // It should log "x = 5"
But instead, it logs v = 5.
Is there a way to store the variable name, and to log the variable name correctly?