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. :)