JavaScript Error messageProperty

JavaScript Error(错误) 对象JavaScript Error Object


Definition and Usage

The message property is used to set or return the error message.

Tip:We can also refer to thenameproperty to output more details about the error.

Syntax

errorObj.message

Parameter Description:

  • None.

Return Value

Returns a string representing the error message.

Browser Support

Property
message Yes Yes Yes Yes Yes

Example

Example

Returns an error message (the "adddlert" function is not defined):

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

Try it Yourself »

JavaScript Error(错误) 对象JavaScript Error Object

Other Extensions