Get object value by property reference not working

2019-08-21 19:35发布

问题:

This is my object:

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])
    }
}

if I call getNote('drive') it returns my object value as expected EXCEPT iOS returns 'nothing', undefined.

How do I get this to work on iOS?