javascript - Access the content of a variable who's name is in another variable -


this question has answer here:

i have 2 variables, 1 holds info object, , named extra_info + id of object. other holds name variable:

selector = 'extra_info' + subscid; 

i trying access data stored in variable holds info, can't seem access it. stupid, know :-)

edit: so, name of variable in end need access is:

extra_infoxxxxx

where xxxxx stored in subscid.

no quotes:

selector = extra_info + subscid; 

or, , i'm loathe suggest because it's red flag of bad design, can use eval():

selector = eval('extra_info' + subscid); 

(obilgatory "eval evil" link)


edit

it sounds should stored extra_info in array object, subscid indexes properties!

to access, extra_info[subscid].


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -