Say I have this code...
var personA = {
name: "john"
}
var personB = {
name: "john"
}
function doSomething(o) {
alert("Var is: " + o.toString()); // I need to convert 'o' to the object name
}
doSomething(personA);
doSomething(personB);
I want the alert output to be...
Var is: personA
Var is: personB
But I can't figure out how to get the name as string of the object?
personA/personBin the output?? The names of the variables? Something tells me this is an X/Y problem -- you've asked about Y because you think you need Y to solve problem X, but it's likely that there's a better way to solve problem X than the above.