I need to get a variable name outside of a function when requested inside one. For example:
var foo = "Hello World!";
myFunction(foo);
function myFunction(oof) {
console.log("This says foo: '" + /*Stuff to get foo variable name*/ + "'";
}
Is it even possible? I can't find answers anywhere. I can use jQuery or normal js. I am using this to put positions in a piece's class. Like e4
into a class that had e
and n4
(n is so it can be var name) as parameters for the function to position the piece. So I can't just use e4
in class, because not all pieces are on that square. Please help as this is needed to progress on my project, unless someone knows another workaround(if there is, I will test and get back to you).