I have string which contains variable name. I want to set variable reference to another variable.
for e.g.
var abc = 'ABCValue'; // variable
var str = 'abc'; // string which is having variable name
function set(variableName){ // variableName = 'abc';
var newVar = variableName.replace(/["']/g, ""); // var newVar should have value of abc variable which is 'ABCValue'
}
I tried replacing single and double quotes from the string to make that value to pose as a variable but it's not working out for me.
Any suggestions?
Thanks.