This way I could have a function that says whatever_way_you_do_this = something. Is this possible? Basically I could tell a function which variable I want to set by giving it a string that holds the name of the variable.
Thanks
This way I could have a function that says whatever_way_you_do_this = something. Is this possible? Basically I could tell a function which variable I want to set by giving it a string that holds the name of the variable.
Thanks
If it is a global variable named myVar
, you can use:
window["myVar"]
Given:
var x = {
myproperty: 'my value'
};
You can access the value by:
var value = x['myproperty'];
If you're looking for a global variable, then you would check its container (window
);
var value = window['x']['myproperty'];
You can use eval(variableString); Readup on eval(); I am also new, so please proceed with caution as many don't recommend using eval();
Thanks, Mahesh Velaga.