是否可以在JavaScript中的关联数组上调用'.toString()'。toString()JS关联数组
var theString = jsonData['item'].toLowerCase();
var theString = jsonData.item.toLowerCase();
这些都不适合我在将数组项目的值转换为小写。
在PHP我可以做到这一点:
strtolower($array['item']);
感谢提前:)
编辑: 这里是我的确切代码:
var correctAnswer = jsonData[setname][qname]['answers'][answerval];
if(lockcase == false){
orrectAnswer = correctAnswer.toString().toLowerCase();
}
这里是从消息Chrome调试菜单:
未捕获TypeError:无法调用方法't未定义
对不起,这似乎并没有工作。 我想你不能这样做,因为它被解释为函数被解释为数组的子对象。 –
@HelloInvader所以你的意思是返回一个布尔值? – 0x499602D2
@HelloInvader查看我的更新。它应该工作。 – 0x499602D2