0

I'd like to create variables with dynamic name and assign to it some values

i have a config array and for each of the value i need a corresponding variable created to which i can assign a new instance of a function

var beta = ["a","b","c"];

for (var i=0 ; i<beta.length, i++){
   // do something
}

it would result in creation of the 3 variables

var valueA = new Var.func(a);
var valueB = new Var.func(b);
var valueC = new Var.func(c);
Suren Srapyan
  • 66,568
  • 14
  • 114
  • 112
Nicc
  • 777
  • 3
  • 8
  • 19
  • 2
    You can keep the values in an array instead of trying to create different variables. Or may be JSON object – Anurag Sinha Jan 10 '17 at 09:59
  • Why do you want to create these variables? Please specify your use-case appropriately. – 31piy Jan 10 '17 at 10:00
  • @31piy so that i can access them later on such as valueA.doSomething() or valueB.doSomething() – Nicc Jan 10 '17 at 10:07

0 Answers0