I am passing a JSON object and an array to a Javascript function, but the array acts empty when I alert it unless I alert a specific value.
function myFunction(jsonObj, array){
alert(array['item1']['name']); //alerts "item1"
alert(array); // alerts "" (not [object] as I'd expect)
alert(array.join('')); // alerts ""
}
What am I missing?
I’m developing with phonegap on xcode and also using jQuery and Jquery Mobile
Seems like you are using an array with string indexes. That won’t work well:
Use an object instead:
Use arrays only with numeric indexes.