The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

message Property (Error) (JavaScript)

Returns an error message string.



Required. Instance of Error object.

The message property returns a string that contains an error message associated with a specific error.

The description and message properties provide the same functionality. The description property provides backwards compatibility; the message property complies with the ECMA standard.

The following example causes a TypeError exception to be thrown and displays the name of the error and its message.

    // Cause an error.
    var x = y;
    document.write ("Error Message: " + e.message);
    document.write ("<br />");
    document.write ("Error Code: ");
    document.write (e.number & 0xFFFF)
    document.write ("<br />");
    document.write ("Error Name: " +;

The output of this code is as follows.

Error Message: 'y' is undefined
Error Code: 5009
Error Name: TypeError

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Applies To: Error Object (JavaScript)

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft