I want to construct javascript instruction dynamically
the original instruction is :
var chou = eval('(' + returnResult + ')').attribute;
I want to pass the attribute as variable is it possible?
I have tried :
var chou = eval('(' + returnResult + ')').eval(baseentity);
but it doesn't work.
I'll be optimistic and assume that returnResult
is JSON.
Then you can do
var chou = JSON.parse(returnResult)[baseentity];
If it's not exactly JSON but you trust the source enough to use eval, then you could do
var chou = eval('(' + returnResult + ')')[baseentity];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.