Computer >> Computer tutorials >  >> Programming >> Javascript

What are the different types of errors in JavaScript?


Besides the generic Error constructor that can be used to create custom errors, there are seven other core error constructors in JavaScript. These are −

  • EvalError −Creates an instance representing an error that occurs regarding the global function eval().

  • InternalError −Creates an instance representing an error that occurs when an internal error in the JavaScript engine is thrown. For Example: "too much recursion"

  • RangeError  − Creates an instance representing an error that occurs when a numeric variable or parameter is outside of its valid range.

  • ReferenceError −Creates an instance representing an error that occurs when de-referencing an invalid reference.

  • SyntaxError −Creates an instance representing a syntax error that occurs while parsing code in eval().

  • TypeError −Creates an instance representing an error that occurs when a variable or parameter is not of a valid type.

  • URIError −Creates an instance representing an error that occurs when encodeURI() or decodeURI() are passed invalid parameters.