IE doesn’t like trailing commas
I had this seemingly undetectable bug on one application I made using javascript. It was running fine on Firefox, no errors or warnings. But when my client checked it out the page wasn’t working. I wasn’t able to test it on IE right away since I only have Firefox installed on my office PC (which is running on Linux with no Wine installed). After arriving home, I looked at the page using IE and yes, the app wasn’t working. It took me the whole night to figure out what was going wrong. I forgot what error message IE was giving me. The only thing I remember is that it doesn’t much about the problem. I read the code one more time, checking for any uninitialized variable or something that I might have overlooked. I was doubtful that it was suffering from cross-browser problems, since I relied mainly on Prototype‘s nice collection of thingies that were already tested for cross-browser compatibility.
I loaded my javascript file on my editor (ConTEXT) and began reading the code again. Half-way through the code, I saw a trailing comma inside an object definition. It kinda looked like this:
someClass.prototype = { someFunction: function() { // do something }, anotherFunction: function() { // do another thing }, }
I almost didn’t notice it. If it wasn’t for the big font I’ve set on my editor, I’d be rewriting a large chunk of my app. Hmmm… looks like Firefox is kind to orphan commas.