JavaScript Error Reference Manual
Error Object
The Error object provides error information when an error occurs.
Example
In this example, we write "alert" as "adddlert" to intentionally cause an error.
Return the error name and error description:
try { adddlert("Welcome"); } catch(err) { document.getElementById("demo").innerHTML = err.name + "<br>" + err.message; }
For knowledge about JavaScript errors, please read our JavaScript Error Tutorial.
Error Object Properties
Properties | Description |
---|---|
name | Set or return the error name. |
message | Set or return the error message (string). |
Non-standard Error Object Properties
Mozilla and Microsoft have defined some non-standard error object properties:
- fileName (Mozilla)
- lineNumber (Mozilla)
- columnNumber (Mozilla)
- stack (Mozilla)
- description (Microsoft)
- number (Microsoft)
Do not use these properties on public websites. They are not applicable in all browsers.