String.toString()

JavaScript1.1+, JScript1.0+, ECMAScript1.0+ NES2+, Nav3+, IE3+ Syntax

							string.toString()

String.toString()

Description

The toString() method of the String object, if invoked on the core String object, will return the object type or the name of the constructor that created the object. This will be something like the following:

function String() { [native code] }

If it is invoked on an instance of the String object, it will contain the source string of the instance you created. In Listing 6.259, the result of this application of the method should be something like the following:

Hello, World!

Example

Listing 6.259 creates an instance of the String object. The toString() method is then applied to the instance and the ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.