标签: javascript arrays object key var
我有一个这样的对象: var object = {"American":[{"question":"What is the capital?", "answer":"..."}, ... ]}; 我还有一个变量: var language = "American"; 所以,我的问题是:我如何使用所谓的语言变量作为数组的关键所有问题?我已经尝试过了: object.language[0].question和object.[language][0].question。
var object = {"American":[{"question":"What is the capital?", "answer":"..."}, ... ]};
var language = "American";
object.language[0].question
object.[language][0].question