Skip to content

IE JS Error: Expected identifier, string or number

Apr 30, 2009 1 min read #javascript

This post is more than 18 months old. Technology changes quickly, so some of this content may be out of date (but that's not always the case). Please verify any technical or programming information against the current release.

I just ran into this a bunch - works fine in FireFox … of course.

Well apparently, Internet Explorer won’t allow you to have a trailing comma in a array or object definition. Let me show you:

functionCall({
  options: {1,2,3},
  others: {1,2,3},
});
javascript

The trailing comma after the other’s line is making IE expect another identifier. So, just strip it out so that line is now:

others: {1,2,3}
txt

And you should be golden!

Now, if only IE told me what line the error was on ;)

(For those who need a tip, I loaded up the site in firefox with jsview extension - and went to view all js. Then do ctrl-L to jump to a line - and type in the line number that IE mentions… see if there is something around there that looks like this scenario)