I have the following in my HTML5 code which makes use of javascript:
var myObj = localStorage[dataObj];
alert(myObj);
alert(myObj.City);
When I do alert(myObj) it shows {“ID”:68,”City”:New York} which is what is in var.
I now need to get the value of City. I do the following but it shows as undefined:
alert(myObj.City);
I also tried
alert(myObj[0]:City) but that did not work as well
myObjis a string, it needs to be parsed into an object.P.S.
console.logis much better for debugging thanalert.