I am trying to use a variable as another variables name. For example, I have the following:
var dynamicname = 'name1_'
And I am trying to set it as the name of a new variable like this:
dynamicname + '2' = 'myvalue'
This obviously isn't working but is there a way to achieve this? Would eval
be suitable?