In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "what are the common types of errors in Js". Interested friends may wish to have a look at them. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the common types of errors in Js.
Error types in JavaScript
Error
EvalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError
Error
Error is the most basic error type, and all other error types inherit from this type. Therefore, all types of errors share the same set of properties. This type of error is rare. Errors thrown by developer customizations are generally used.
EvalError
This error is thrown when an exception occurs using the eval () function. Two situations can go wrong:
New eval (); eval = foo
The combination of the above two means that there is no direct call to the eval function, but the error of new or re-assignment is basically not encountered, because the eval function is not used much. It is important to note, however, that eval is a keyword.
RangeError
This error is triggered when the value is out of range. For example, when using new Array (), pass a negative number or a number that exceeds the maximum length of the array (4294967295), such as Number.MAX_VALUE,Number.MIN_VALUE. Note that recursive explosions also have this error.
RangeError: range error
RangeError is an error that occurs when only one is out of the valid range. There are several main cases, the first is that the array length is negative, the second is that the method parameters of the Number object are out of range, and the function stack exceeds the maximum value.
/ / 3.RangeError: range error / / 3.1Array length is negative [] .length =-5 / / Uncaught RangeError: Invalid array length// 3.2The method parameter of the Number object is out of range var num = new Number (12.34) console.log (num.toFixed (- 1)) / / Uncaught RangeError: toFixed () digits argument must be between 0 and 20 at Number.toFixed// indicates that the purpose of the toFixed method is to round a number to a specified number of decimal places Parameter is the number of decimal places specified Is a value between 0 and 20, including 0 and 20, and some implementations can support a wider range of values. If this parameter is omitted, 0 will be used instead. ReferenceError
This error usually occurs when the variable cannot be found, such as:
Var a = b * uncovered ReferenceError: b is not defined
At this point, you need to check this variable.
SyntaxError
When the Javascript language parses the code, the Javascript engine throws a SyntaxError when it finds an tokens or token order that does not conform to the syntax specification.
SyntaxError: syntax error / / 1. SyntaxError: syntax error / / 1.1 variable name does not conform to the specification var 1 / / Uncaught SyntaxError: Unexpected numbervar 1a / / Uncaught SyntaxError: Invalid or unexpected token// 1.2 assign the keyword function = 5 / / Uncaught SyntaxError: Unexpected token =
Then it may also be due to the use of Chinese symbols, the lack of parentheses, such an error is also a grammatical error
/ / Uncaught SyntaxError: Invalid or unexpected token
TypeError
This mistake is often encountered in JavaScript, whether it is a beginner or a veteran. When a type other than that is stored in a variable, or when accessing a method that does not exist. Can lead to this kind of mistake. But in the final analysis, it is because the type of the variable does not meet the requirements when performing type-specific operations. For example:
Var o = new 10 * * a.style.widht = "10px"
Beginners encounter a lot about styling, which is usually caused by the inability to get elements.
URIError
When using encodeURI or decodeURI because the URL format is not correct, it will cause a URIError error. Such mistakes are also rare.
At this point, I believe you have a deeper understanding of "what are the common types of errors in Js?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.