我有一个包含一些未指定函数的字符串。 有没有办法eval()这个字符串并存储编译为对象或数组的结果函数?
执行eval(string)之后所需的输出:
you have selected AL-AL.jpg to go to this location: closing
you have selected AL-AN.jpg to go to this location: closing
you have selected AL-AV.jpg to go to this location: closing
you have selected AL-CA.jpg to go to this location: closing
you have selected AL-CL.jpg to go to this location: closing
you have selected AL-CM.jpg to go to this location: closing
you have selected AL-AL.jpg to go to this location: merch2
you have selected AL-AN.jpg to go to this location: merch2
you have selected AL-AV.jpg to go to this location: merch2
you have selected AL-CA.jpg to go to this location: merch2
you have selected AL-CL.jpg to go to this location: merch2
you have selected AL-CM.jpg to go to this location: merch2
如果我随后使用另一个字符串(也可能同时包含相同名称的函数)执行此操作,则我不希望它覆盖第一个字符串:
{ a: f() ,
b: f() ,
c: f() }
这里的两个a实际上是不同的功能。