

In this example, the programmer accidentally used a single equals instead of two.

The most common example of this error is with if-clauses: if(doSomething() = 'somevalue') Related errors: Uncaught exception: ReferenceError: Cannot assign to ‘functionCall()’, Uncaught exception: ReferenceError: Cannot assign to ‘this’Ĭaused by attempting to assign a value to something that cannot be assigned to. Uncaught ReferenceError: Invalid left-hand side in assignment With this error, the line number will usually point at the correct location.
#Javascript iexplorer how to#
How to fix this error: Ensure the function name is correct. The other variations such as “number is not a function” occur when attempting to call a number like it was a function. Since object properties that don’t exist are undefined by default, the above would result in this error. This error typically occurs if you are trying to call a function in an object, but you typed the name wrong. Occurs when attempting to call a value like a function, where the value is not a function. Related errors: number is not a function, object is not a function, string is not a function, Unhandled Error: ‘foo’ is not a function, Function Expected Uncaught TypeError: undefined is not a function Errors from Firefox are similar, but do not always include the first part, and recent versions of Internet Explorer also give simpler errors than Chrome – but in this case, simpler does not always mean better. Other webkit-based browsers, like Safari, give errors in a similar format to Chrome.
#Javascript iexplorer code#
For example in this case it literally means that the code attempted to use undefined like it was a function. With error messages, you have to read them very literally. undefined is not a function: This is the message part.Uncaught means the error was not caught in a catch statement, and TypeError is the error’s name.

Uncaught TypeError: This part of the message is usually not very useful.The structure of the error is as follows: Understanding the structure helps understand the errors, and you’ll have less trouble if you run into any errors not listed here.Ī typical error from Chrome looks like this: Uncaught TypeError: undefined is not a function How to read errors?īefore the list, let’s quickly look at the structure of an error message. Different browsers can give you different messages for the same error, so there are several different examples where applicable. Wouldn’t it be useful to have a list where you could look to find out what they mean and how to fix them? Here you go!īelow is a list of the strange errors in JavaScript. JavaScript can be a nightmare to debug: Some errors it gives can be very difficult to understand at first, and the line numbers given aren’t always helpful either.
