In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "what are the error types of javascript". In daily operation, I believe many people have doubts about what are the error types of javascript. Xiaobian consulted all kinds of information and sorted out simple and easy to use operation methods. I hope to answer your doubts about "what are the error types of javascript"! Next, please follow the small series to learn together!
JavaScript error types are: 1, Error;2, InternalError;3, EvalError;4, RangeError;5, ReferenceError;6, SyntaxError;7, TypeError;8, URIError.
Operating environment of this tutorial: Windows 7 system, Javascript version 1.8.5, Dell G3 computer.
ECMS defines the following eight error types and throws different error objects when an error occurs.
Error
InternalError
EvalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError
1. Error
Error is the base type from which all other error types inherit, so all error types share the same properties (all methods on error objects are methods defined by this default type). Browsers rarely throw errors of the Error type, which is primarily used by developers to throw custom errors.
For example, it is often used in interceptors/navigation guards.
II. InternalError
Errors of the InternalError type are thrown by browsers when the underlying JavaScript engine throws an exception. For example, excessive recursion leads to stack overflow. This is not the type of error that code normally handles, and if it does occur, there is probably something wrong or dangerous in the code.
III. EvalError
An EvalError type error is thrown when an exception occurs using the eval() function. ECMA-262 states,'If the eval attribute is not called directly (i.e. its name is not used as an Identifier, i.e. MemberExpression in CallExpression).'
Basically, if eval() is not treated as a function call, it will report an error.
Errors thrown by different browsers vary, but they are rarely used in this way, so they are not common.
IV. RangeError
RangeError is thrown when a value is out of bounds. For example, if an array is defined with an unsupported length, such as-20. Or if no stop condition is set for recursion.
This type does not occur much in JavaScript.
5. ReferenceError
ReferenceError occurs when an object cannot be found. (This is the cause of the famous "object expected" browser error). This error is often caused by accessing variables that do not exist.
Example:
SyntaxError
Often occurs when the string passed to eval() contains JavaScript syntax errors, which are rarely used outside eval(). This is because syntax errors in JavaScript code can cause code to fail to execute.
VII. TypeError
TypeErrors are common in JavaScript, mainly when variables are not of the expected type, or when accessing methods that do not exist, especially when using type-specific operations and variables of the wrong type.
Errors occur frequently when there is no validation before passing parameters to a function
VIII. URIError
URIError occurs only when a malformed URL is passed in using encodeURL() or decodeURL(), but it is rare because the above two functions are very robust.
At this point, the study of "what are the error types of javascript" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
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.