This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

toString

Summary

Returns a string representation of an error.

Syntax

error.toString()
date
Required. The error to represent as a string.

Return Value

Returns "Error: " plus the error message.

Examples

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

Attributions

  • Microsoft Developer Network: Article