JavaScript Error.prototype.message Property
The message property of an Error holds the human-readable description of what went wrong.
Description
The message property contains a human-readable description of the error, set by the first argument to the constructor. Together with name, it's what you usually log or show. Built-in error messages differ between browsers, so don't write code that depends on their exact wording.
You can include useful context in your own messages, such as the value that was invalid: new RangeError(`Quantity must be 1-10, got ${qty}`). Avoid putting sensitive data, such as passwords or tokens, in messages, since they often end up in logs.
When showing errors to users, a friendly message written for them is usually better than the technical message, which you can log for developers instead. Converting an error to a string gives "Name: message".
Syntax
error.messageValue
A string describing the error.
Example
Browser Support
The following information will show you the current browser support for the Error.prototype.message property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





