I have a javascript variable called temp
.
ultimately, temp
will equal one of many strings, let's say for now it equals "stack"
.
how can I set the variable (in this case stack
, which is an existing global variable) to equal the string "stack"
, dynamically?
So if at another point in time, temp
is set to "overflow"
, how can i set overflow = "overflow"
?
Thanks for your help!
i've seen some answers mention eval
and others mention using bracket ~ this[variable]
, but can't seem to figure this out..