Crashing JavaScript in Internet Explorer

Most of the JavaScript programmers has probably “broken” their scripts in Internet Explorer at least once in their live. Sometimes it is a tiny bug that can crash your scripts. One of that bugs can show up when using object literals.

When adding a few key-value pairs to a object literal, most developers just copy and past the previous row, including the comma and then edit the key name and its value. Example:

var foobars {
   foo1: "bar1",
   foo2: "bar2",
   foo3: "bar3", // <-- get rid of that comma!
}

This code will let you crash your JavaScript in Internet Explorer and it can make you desperate when you have to debug it. So, watch out when using object literals. :)

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam protection by WP Captcha-Free