Export (0) Print
Expand All

toString Method (Error)

Returns a string representation of an error.

error.toString()

date

Required. The error to represent as a string.

Returns "Error: " plus the error message.

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

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.

Show:
© 2014 Microsoft