Javascript 通过属性引用获取对象值在iOS上不起作用
这是我的目标:Javascript 通过属性引用获取对象值在iOS上不起作用,javascript,ios,object,ios7,mobile-safari,Javascript,Ios,Object,Ios7,Mobile Safari,这是我的目标: var charsObj = {"drive":{"status":"inprogress","data":"some data","history":"the text of my history"}} function getNote(x) { if ( x in charsObj) { console.log(charsObj[x]) } else { console.log('nothing', charsObj[x])
var charsObj = {"drive":{"status":"inprogress","data":"some data","history":"the text of my history"}}
function getNote(x) {
if ( x in charsObj) {
console.log(charsObj[x])
} else {
console.log('nothing', charsObj[x])
}
}
如果我调用getNote'drive',它会按预期返回我的对象值,除了iOS返回'nothing',未定义
如何在iOS上运行此功能?在您的代码中,charsObj是在哪里创建的?更新了示例。如果charsObj中的x-有效吗?-如果查索布。hasOwnPropertyx@tymeJV:两种方法都试过了。没什么区别。