JS Common error types

Source: Internet
Author: User

Before you solve the error, you must first learn to read the wrong information

Eg:uncaught TypeError: ... is not a function

Uncaught represents an error that is not caught by a catch statement
TypeError is the wrong type
A function is a message body

The whole meaning is: The code tries to ... Used as a function, but the ... is not a function

1.Uncaught Typeerror:cannot Read property ' of undefined

The common one is that when you render a UI component, the initialization of the state is inappropriate, and when you read an undefined object's properties or call its methods, the error appears in Chrome.

2.TypeError: ' Undefined ' isn't an object

This is an error that occurs when a property is read in Safari or a method on an undefined object is called, and Safari uses a different error message prompt.

3.TypeError: ' null ' is not a object
This is an error that occurs when you read a property or invoke a method on an empty object in Safari, and Safari uses a different error message prompt.

Undefined is usually a variable that has not been allocated, and Null indicates that the value is empty. To verify that they are not equal, try using the strict equality operator = = =

This error can occur when you try to use elements in JavaScript before loading elements. Because the DOM API returns a value of NULL for a blank object reference.

4. (unknown): Script error
This type of scripting error occurs when an uncaught JavaScript error (caused by an error raised by the Window.onerror handler, rather than captured in Try-catch) is restricted by the browser's cross-domain policy. This is a browser security measure designed to prevent data from being passed across domains, otherwise communication will not be allowed.

5.typeerror:object doesn ' t support property
This is an error that occurs in IE when you call an undefined method. You can test it in the IE developer console.

6.TypeError: ... is not a function
Error generated in Chrome when calling undefined function

7.Uncaught Rangeerror:maximum Call Stack
When you invoke a non-terminating recursive function or pass a value to a function that is out of range, the error is reported, check the recursive invocation of the function, and ensure that the function is not infinite recursion

8. Typeerror:cannot Read property ' length ' of undefined
Because the length property of an undefined variable is read, the length of the definition is usually found in the array, but you may encounter this error if the array is uninitialized or the variable name is hidden in another context.
var testarray = ["Test"];
function TestFunction (Testarray) {
for (var i = 0; i < testarray.length; i++) {
Console.log (Testarray[i]);
}
}
TestFunction ();
When you declare a function with a parameter, these parameters become local parameters within the scope of the function. This means that even if you have a variable named Testarray outside of your function, a parameter with the same name in a function will also be treated as a local parameter.

9.Uncaught Typeerror:cannot Set Property ... of undefined
When trying to access an undefined variable, it always returns undefined, and we cannot get or set any undefined properties.

10.ReferenceError: ... is not defined
This error is raised when you try to access an undefined variable or a variable that is outside the current scope.

11.Uncaught Exception:ReferenceError:Cannot assign to ' this '
This error occurs when attempting to assign a value to a variable that cannot be assigned, making sure that the return value of the function function or the This keyword is not assigned a value.

12.Uncaught typeerror:converting Circular Structure ToJSON
This error always occurs when using Json.stringify to serialize an object that has a circular reference, removing the circular reference that will be converted to the inside of the JSON string object.

13.Unexpected token;
The line number of the error message sometimes does not point to the correct position when a parenthesis or semicolon is missing.

14.Uncaught syntaxerror:unexpected Token illegal
The string literal lacks a closed quotation mark, ensuring that all strings contain closed quotation marks.

JS Common error types

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.