(.. var fooName), , eval:
eval('var ' + foo + bar);
eval, , (. ).
It is best to set an object property. Defining a global variable is equivalent to setting a property for a global object window:
window[foo+bar] = 'someVal';
You can substitute windowfor another object if necessary.
source
share