Published Jul 23, 2021Updated Sep 9, 2021
Contribute to Docs
name and a
message property. The
name is the general type of the error, and the
message is a human-readable description of the specific error that happened.
Thrown errors are caught by the next outer
catch block of a
try...catch...finally statement. They can also be thrown intentionally by the
The Error Object
The error object holds information about the exception that was thrown in its two properties:
nameSets or returns an error name. (Type of Error)
messageSets or returns an error message. (Description of specific instance.)
The following types of error can be returned by the
- “RangeError” A number “out of range” has occurred
- “ReferenceError” An illegal reference has occurred
- “SyntaxError” A syntax error has occurred
- “TypeError” A type error has occurred
- “URIError” An error in encodeURI() has occurred
These are some example messages for various types of errors:
- invalid array length
- invalid date
- “x” is not defined
- assignment to undeclared variable “x”
- “x” is a reserved identifier
- a declaration in the head of a for-of loop can’t have an initializer
- “x” is not a function
- “x” is read-only
- malformed URI sequence
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Includes 8 Courses