javascript - Access the content of a variable who's name is in another variable -
this question has answer here:
- “variable” variables in javascript? 7 answers
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);
edit
it sounds should stored extra_info
in array object, subscid
indexes properties!
to access, extra_info[subscid]
.
Comments
Post a Comment