如何从JavaScript中的字符串中获取变量/属性?
字符串for (unsigned int i = 0; i < count; i++)
{
boost::thread z(CommandLineRun, nIndex[i].line); // refer to the original string.
z.detach(); // making this explicit makes your intent clear
}
void CommandLineRun(std::string Command) // getting a copy of the string
{
int systemRet = system(Command.c_str());
if(systemRet == -1){
// The system method failed
}
}
返回obj.val
的值。将obj.val
添加到字符串的开头和结尾足够了吗?
谢谢! :)
与你们有些人建议的帖子不同,我想要的值没有字符串键。
答案 0 :(得分:0)
您可以使用variable
或string
this[yourString]
获得scope[yourString]
的价值。
var someVar = "Hello world!";
this["someVar"] //this print value of variable name "someVar"
var obj = {}; obj.var = "some object!";
this["obj"]["var"] //this will get value of object property with "var"