Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 通过属性引用获取对象值在iOS上不起作用_Javascript_Ios_Object_Ios7_Mobile Safari - Fatal编程技术网

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:两种方法都试过了。没什么区别。