String.toSource() (Method)

Outputs a string formatted as a string literal contained in a string.


ECMAScript edition - 3
JavaScript - 1.3
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.06
Property/method value type:String primitive
JavaScript syntax:-myBoolean.toString()

This is an alternative way to deliver a string primitive version of a String object's value. In this case, it is formatted as a string literal and can then be used in an eval() function to assign another string.

If you run the example below, it should yield this as a result:

(new String("ABCDEF"))

The result of calling this method is a string version of the String object formatted as a string literal.

Example code:

   // Create a number and then examine its source
   myString = new String("ABCDEF");