Function.toSource()

JavaScript 1.3+, JScript 1.0+ Nav4.06+, IE 3+, Opera3+ Syntax

							function.toSource()

Description

The toSource() method of the Function object allows you to create a copy of an object.

Example

Listing 6.131 uses the toSource() method on a newly created string. Running this script in a browser returns the following:

(new String("This is the source"))
Listing 6.131 Using the toSource() Method
 <html> <body> <script lanuguage="JavaScript"> <!–– Hide // Create a new String instance var aString = new String("This is the source"); // Call the toSource() method bString = aString.toSource(); // Write the returned value of calling the toSource() // method to the page. document.write(bString); // End Hide ––> </script> </body> ...

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.