Error expected identifier string or number

Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Some users are reporting occasional JS errors on my site. The error message says "Expected identifier, string or number" and the line number is , which is just an arbitrary number and changes for each report when this occurs.

I scanned my code a bunch of times and ran jslint but it didn't pick anything up - anyone know of the general type of JS problems that lead to this error message? If it appears at a random line, maybe it's part of an object defintion you are creating dynamically. Using the word class as a key in a Javascript dictionary can also trigger the dreaded "Expected identifier, string or number" error because class is a reserved keyword in Internet Explorer.

I say error in quotes because it was fine everywhere but on IE. This was under IE6. The problem was related to JSON object creation and an extra comma, such as. IE6 really doesn't like that comma after 3. You might look for something like that, touchy little syntax formality issues. This is a definitive un-answer: eliminating a tempting-but-wrong answer to help others navigate toward correct answers.

It might seem like debugging would highlight the problem. However, the only browser the problem occurs in is IE, and in IE you can only debug code that was part of the original document. For dynamically added code, the debugger just shows the body element as the current instruction, and IE claims the error happened on a huge line number.

Possible Javascript Errors: "Expected Identifier, String, or Number"

Just saw the bug in one of my applications, as a catch-all, remember to enclose the name of all javascript properties that are the same as keyword. Also in IE 7. It works fine in Safari and Chrome with no errors in console. IE7 is much less forgiving than newer browsers, especially Chrome.

I like to use JSLint to find these bugs. It will find these improperly placed commas, among other things.

  • IE ERROR: Expected Identifier, string or number.
  • "Expected identifier, string or number" error when using IE7 - Meta Stack Exchange.
  • Progress KB - "Expected identifier, string or number" error in IE7;
  • NagVis Error with Internet Explorer 8 (Expected identifier, string or number).
  • registry of sex offenders in minnesota.
  • [Solved] IE9 SCRIPT Expected identifier, string or number - CodeProject.

You will probably want to activate the option to ignore improper whitespace. In addition to improperly placed commas, at this blog in the comments someone reported:. I've been hunting down an error that only said "Expected identifier" only in IE 7. My research led me to this page. After some frustration, it turned out that the problem that I used a reserved word as a function name "switch".

THe error wasn't clear and it pointed to the wrong line number. This error occurs when we add or missed to remove a comma at the end of array or in function code. It is necessary to observe the entire code of a web page for such error. This sounds to me like a script that was pulled in with src, and loaded just halfway, causing a syntax error sine the remainder is not loaded. Another variation of this bug: I had a function named 'continue' and since it's a reserved word it threw this error. I had to rename my function 'continueClick'.

You may hit this problem while using Knockout JS.

  • to search a person for concealed weapons?
  • sex offenders nys st lawrence county.
  • mapState() and the Rest/Spread Operator In Edge - vuex - Vue Forum.

If you try setting class attribute like the example below it will fail:. I too had come across this issue.

"Expected identifier, string or number" script error when accessing MapInfo Pro Geocoding services

I found below two solutions. Same as mentioned by others above, remove extra comma from JSON object. Because of this it was triggering browser's old mode which was giving JS error for extra comma. Copy the code from the console into your IDE. Most IDE's perform error checking on the code and highlight errors.

Had the same issue with a different configuration. This was in an angular factory definition, but I assume it could happen elsewhere as well:.

How to Fix Errors in Your Java Code

This can also happen in Typescript if you call a function in middle of nowhere inside a class. For example. Function calls, like console. Not in the area where you should be declaring class fields. We now integrate with Microsoft Teams, helping you to connect your internal knowledge base with your chat. Learn more.

Add your solution here

Asked 9 years, 9 months ago. Active 8 months ago. Viewed k times. The first thing that comes to mind is the obvious. Could it be an array literal that's got a dangling comma at the end? Also, what's "Mozilla 4. Either having a trailing comma when inappropriate, or using a JavaScript reserved word. In your case, you have 2 unnecessary commas. Below is the correct code snippet, with comments where I removed the commas. I actually did a blog post and video explaining the error and showing examples and fixes. IE8 errors when defining a Javascript object?

IE Debugger Error: element. Rather than work round compatibility mode you can force non-compatibility mode with How do you check for an empty string in JavaScript? How can I convert a string to boolean in JavaScript?