JavaScript Error message


Example

Return an error message:

try {
  adddlert("Welcome guest!");
}
catch(err) {
  document.getElementById("demo").innerHTML = err.message;
}
Try it Yourself »

Description

The message property sets or returns an error message.

See Also:

The name property of the Error object.


Syntax

errorObj.message

Return Value

A string describing the error (varies between browsers).

Browser Support

error.name is an ECMAScript1 (ES1) feature.

ES1 (JavaScript 1997) is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes

Related Pages

JavaScript Tutorial: JavaScript Errors

JavaScript Reference: The name property


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.