I had an array in PHP
vars = array('Date','Name','Number');
Using the "vars" array I could create more arrays using the names in the list:
for($i = 0; $i < count($vars); $i++){
${$vars[$i]} = "Something";
}
Now, I have an array in JavaScript and I want to do the same: create variables using a list' names in a loop. This variables are going to be arrays and I just can't use a common array for all the variables. What can I do?
I know it's possible to do "variable" variables in JavaScript:
var obj = {}
obj.foo = 42;
var bar = 'foo';
console.log(obj[bar]);
But I don't know how to use it in a loop from another array