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? .

blog comments powered by Disqus

Possibly related posts

23 Nov 2007 »
Forms in CodeIgniter Views
15 Aug 2007 »
A study of PHP Frameworks
26 Oct 2007 »
WordPress Plugin: Recent Posts grouped by year, month, and day
21 Oct 2007 »
Trouble with jQuery Ajax load() method
02 Mar 2009 »
Installing Jekyll on Ubuntu 8.10