IE7 Error: Expected identifier, string or number

Published on Thursday, 29 November 2007.

UPDATE 4 March 2009: I have added useful information, instead of just the link to the solution.

The cause, reason, or explanation for this issue is: an extra comma in a Javascript Object declaration.

For example:

var Test = {
    hello: function () {
        alert('hello');
    },

    bye: function () {
        alert('bye');
    },
};

You should notice that after the bye() function, there is a comma that, to be strict, is not really needed.

Most browsers are ok with that extra comma. However, on Internet Explorer browsers (at least on IE6, and IE7), this extra comma can break an application completely. So, by code convention, you must never leave extra commas, after declaring object methods/functions. That is, unless you don't want to support IE.

Here's a link with a different explanation: Expected identifier, string, or ... say what? .