toString Method (Error)

Returns a string representation of an error.

Syntax


error.toString()  

Parameters

date
Required. The error to represent as a string.

Return Value

Returns "Error: " plus the error message.

Example

The following example illustrates the use of the toString method with an error.

var myError = new Error();  
myError.message = "My Error";  
var errorString = myError.toString();  
document.write(errorString);  

// Output: Error: My Error  

Requirements

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 Store apps (Windows 8 and Windows Phone 8.1). See Version Information.