I have the JS below.
The error in IE8 I'm getting is:
's' is null or not an object
Any ideas would be appreciated?
var t = [
{s: "blah", e: "blah blah"},
{s: "blah", e: "blah blah"},
{s: "blah", e: "blah blah"},
{s: "blah", e: "blah blah"},
];
var obj = t[0];
for (var prop in obj) {
console.log(prop+": "+obj[prop]);
}
for (var i = t.length - 1; i >= 0; i--) {
var l = t[i];
var s = l.s;
console.log(s);
}
You have a comma after the last object in your t array. Remove it, because it is getting an undefined as your first object in the loop, because in IE8 it would not initially throw an error but it would acquire an empty object. This is the reason why you get the error.
Your code:
var t = [
{s: "blah", e: "blah blah"},
{s: "blah", e: "blah blah"},
{s: "blah", e: "blah blah"},
{s: "blah", e: "blah blah"},
undefined // How IE8 parses it and your loop starts here
];
This wouldn't throw errors:
var t = [
{s: "blah", e: "blah blah"},
{s: "blah", e: "blah blah"},
{s: "blah", e: "blah blah"},
{s: "blah", e: "blah blah"} // No comma so array is terminated here
];