Internet Explorer Javascript Errors

Evolution and Geneone have been plagued by some Javascript errors in Internet Explorer over the last few weeks. To be honest, the number of people who play Evolution or visit my blog using IE are so low that no one has actually bothered complaining.

These errors included Object expected and "Expected identifier, string or number". I’ve never tried to actually fix these errors before because IE’s script debugging really really sucks. 

Windows Scripting Debugger can be a useful tool for debugging Javascript but be warned that it is very very unstable and severely affects the stability of your computer.

Expected identifier, string or number

This was an annoying little bug caused in a class because of a comma at the end. In Javascript you have lists like:

var list = { opacity: 0.5, height: 0.5} 

Similar syntax is used to group functions:

var MyFuncs = {
bleh : function() {},
bleh2 : function() {},

The above code should work fine in real web browsers such as Firefox. IE will give a screwed up error such as "Expected identifier, string or number". Just remove the comma after the last function and the error be gone.

Object Expected

If you document.getElementsById(‘nonexistantitem’) in Firefox and try to retrieve an attribute such as previousSibling, Firefox won’t complain. IE will. This was causing issues as I had a little bit of Javascript which searched for the "Entry Title" box above the "Message" box in the Object Creation forms. On pages where the Entry Title field weren’t shown, IE would freak out as the previousSibling would return False.

I should thank neonDragon for his assistance in resolving these issues

39 thoughts on “Internet Explorer Javascript Errors

  1. The actual syntax is:

     var list = {

     a: function() {


    b: "some value"



    (note the semicolon at the end)


    Also, it’s good practice to actually error check your code.. e.g.:


    var elm = document.getElementById(‘whatev’);


    if(elm) { … } 

  2. Ah cool, thanks for the information. The problem was I was trying to look for the element which came 2 places before a specific element. So I had code like:


    It was possible that .previousSibling.previousSibling didn’t exist so I had to check for that before calling previousSibling again twice.

    Thanks for the info about JSLint, should come in really handy! 

  3. Thank you for posting this.  I have a JSON object that is >60K and it would have taken me forever to find that I have an extra comma at the end.  You just saved me a ton of time.

  4. You went probably way too far – too much bother to fix that as interestingly enough its mostly M$ own sites that also trigger that error message (my favourite being their beta site). Don’t know, dear Microsofties but you happen to test your own web pages with firefox? It WOULD be clever to do so, I’d grant you that

  5. Thank you, thank you, thank you! I just spent half an hour or more wrestling with the "Expected identifier, string or number" error!

  6. Thanks very much for the article.

    I almost crushed my head figuring out what is wrong with my code. The most nasty thing is that Explorer has allowed code to be executed partly, which really disturbs and hides the problem.

  7. Know this was prob an old post but I just wanted to thank you for this  stumbled  upon your blog via google. Thanks a mill  spent way too long trying to figure that one out! IHATE IE!!!

     But thanks 🙂

  8. Thank you, thank you.
    You saved me plenty of time and hair-pulling.
    Bloody little comma, who would’ve known.
    And the useless error message doesn’t help.

    Thanks again.

  9. I’d like to add another Thank You!  Been fighting a stupid IE error for hours, thanks to this page I tracked it down to a trailing comma in an AJAX data array, about a thousand lines away from where IE was bitching about, in a totally different function!

       — hugh

  10. I am using similar kind of editor as this is used for comments typing. I am adding this javascript editor in my website. The problem is if I put some comma like this ( ‘ ) and save in database. Again when i click to edit these text then it won’t show the textarea with value getting from database. Without comma ‘ it works ok.


    Is there any solution or fixes in javascript. thanks 

  11. hi

    I just want to say thank you so much for the information

    i was fighting this bug for about 1 – 2 hours until i found the f***ing comma after searching at the almost the end of the function , now everything is work well

    thanks again

  12. Gee, this posting just solved a problem I was having. I had no clue that this comma I accidently left at the end of an array would break IE. Thanks! 🙂

  13. “Expected identifier, string or number” error comes if we have null has key in some object. E.g.: {null:”TEST”}

  14. Thank you for posting this. I have spent way too many hours trying to get things to work in IEEEEEEEEE (sorry to scream). I think you hit the nail on the head when you talked about internet explore being hard to debug scripts, they are virtually impossible.

  15. It’s for this reason, and that it’s easier to append and they always fall in the same column on the page, that I put the commas at the start of lines instead of the end.

  16. Thanks, this helped me solve the ‘object expected’ problem.
    Does anyone know what the line number in IE javascript error messages refer to? They don’t ever seem to help me find the particular line that contains the problem.

  17. Well guys, actually the IE version is correct as any real programmer knows. The comma is a separator and by inference it follows that after a separator comes another field.

    Now if the the fieled is NULL, which is different from an empty string then of course the program breaks and throws an error.

    Firefox have just handled the exception in a nice way. That said, masking the exception just makes browers more tolerant for the great unwashed. We professionals should still observe the programming rules for accuracy and potential reuse in other environments.



  18. Man , you saved my life , those errors were driving me nuts !!!! until i found this blog and the errors were gone , big thanks for you. keep doing a great job.

  19. Error: Expected identifier
    One more reason for error message saying “Expected identifier” is when we use some reserved keyword in our javascript code. I encountered the same problem. My code was somthing like:

    testFunc = function (test, class) {


    IE gave me error saying “Expected Identifier”. As the error message is not very descriptive I had a tuff time finding out the solution. The actual problem is class is a reserved word in IE browser so we can’t use it in our javascript code.

  20. Yap, IE hates commas (,) on everything… I was lucky enough for IE to display proper error lines so it was a peace of cake finding errors but I can’t imagine what would happen in a larger JS file….


  21. I agree with Pete, FF should not be so nice with errors. Of course, IE’s errors are so cryptic it takes a million years to figure out something as simple as a comma. It was in a totally unrelated location.

    Like Franta, I repeat the question: does anyone know how to interpret the line and char numbers IE reports? It’s not line number in the source html or js document. It doesn’t seem to be line number in the script tag either.

    (My ulterior motive to wishing FF was more strict is that I much prefer debugging js in firebug than in IE. I don’t have Visual Studio, nor would it be convenient to purchase.)

  22. I had this error in IE6 – 9 and tried all different ways with commas etc. My error was because I had used but jQuery and $ in the same function. I usually use jQuery as wordpress conflicts and now do it by habit but the $ was not working, as soon as I made it jQuery all worked.
    Just in case you find this its worth checking.

Leave a Reply

Your email address will not be published. Required fields are marked *