Hello it is possible to access the value of a JavaScript variable by name? Example:
var MyVariable = \"Value of variable\";
function readValue(name) {
//Ran into this today
//Not what I want
var test = 'someString';
var data = [];
data.push({test:'001'});
console.log(test); --> 'someString';
console.log(data); -->
(1) [{…}]
0: {test: "001"} //wrong
//Solution
var obj = {};
obj[test] = '001';
data.push(obj);
console.log(data); -->
(2) [{…}, {…}]
0: {test: "001"} //wrong
1: {someString: "001"} //correct