I have this array (I know, technically there is no such thing as a multidimensional array in javascript) or ‘object’. I want to get the value -888 like so:
var thisPage = 1;
var pagePos = {
0: {
left: '0',
url: 'home',
},
1: {
left: '-888',
url: 'what_we_offer',
},
2: {
left: '-1776',
url: 'clients',
},
3: {
left: '-2664',
url: 'contact_us',
}
};
alert(pagePos[thisPage].left);
It works fine in Firefox, but not IE. Why?
Thanks.
This is because of trailing commas after values of
urlattributes. You can’t have comma after the last value in JSON. The correct syntax is