JavaScript Error message Property
Example
Return an error message (we have written "alert" as "adddlert" to deliberately produce an error):
try {
adddlert("Welcome guest!");
}
catch(err) {
document.getElementById("demo").innerHTML = err.message;
}
Try it Yourself »
Definition and Usage
The message property sets or returns an error message.
Tip: Also see the name property of the Error object.
Browser Support
Property | |||||
---|---|---|---|---|---|
message | Yes | Yes | Yes | Yes | Yes |
Syntax
errorObj.message
Technical Details
Return Value: | A String, representing a description of an error (varies depending on the browser) |
---|---|
JavaScript Version: | 1.0 |
Related Pages
JavaScript Tutorial: JavaScript Errors
JavaScript Reference: The name property