String.toSource()

JavaScript1.3+, JScript3.0+, ECMAScript2.0+ (proposed) Nav4.06+, IE4+ Syntax

							string.toSource()

String.toSource()

Description

The toSource() method of the String object is not defined in the first version of the ECMAScript standard, but is proposed for version 2. If this method is invoked on the core String object, it will return something like the following:

function String() { [native code] }

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

(new String("Hello, World!"))

Example

Listing 6.258 creates an instance of the String object. The toSource() method ...

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.