Javascript oddities in IE8

Well ok, JavaScript almost always behaves oddly in IE8 along with CSS and any other technology that does anything remotely cool.
However, one important oddity is in how IE8 and modern browsers handle arrays.
For example, when listing many items in an array it is common (and can avoid future headaches when modifying code) to write the below:  Note the final comma after the last element.
var array = ["item one", 
"item two", 
"item three",
]
What you end up with in IE8 is the following:
["item one", "item two", "item three", WINDOW OBJECT]
For some reason IE8 throws a window object in the mix when you leave the extra comma in the list. Remove the final comma and IE8 will behave as it is supposed to.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Categories: