How can I retrieve the variable name (user_name1
or user_name2
) from a sample function (GetUserName()
) within itself? This variable name is required to create an object with the same name on the server side for data synchronization purposes.
function GetUserName(){
let result_variable_name = ????; // If (1) then result_variable_name == 'user_name1', if (2) then result_variable_name == 'user_name2'
socket.send("object_name", result_variable_name);
return "Some user name";
}
let user_name1 = GetUserName(); //(1)
let user_name2 = GetUserName(); //(2)
Is it possible to achieve this? How can it be done?