Could someone please point out what is wrong with this code snippet?
HTML:
<div id="res"></div>
Javascript:
var myObject = {
"a" : {
src : "someimagepath_a.png"
},
"b" : {
src : "someimagepath_b.png"
},
};
var image_srcArr = [];
var image_src = "";
for(item in myObject)
{
image_srcArr.push(myObject[item].src);
// additional logic goes here
}
document.getElementById('res').innerHTML = (image_srcArr.join(" & ") + " images used");
Issue encountered:
var image_src = "";
for(item in myObject)
{
image_src = myObject[item].src;
// additional logic goes here
}
This code functions correctly in Firefox and other browsers, but in IE10 myObject[item]
always returns undefined even though there are values within myObject
.