Function.toString()
JavaScript 1.1+, ECMAScript 1.0+, JScript 3.0+ Nav3+, NES2+, IE 4+, Opera3+ Syntax
function.toString()
Description
The toString() method of the Function object is used to convert a function to string. The method converts the function back to the JavaScript source that defines the function. The converted string includes all aspects of the defined function.
Example:
Listing 6.132 shows how the toString() method is used to convert a function to a text string.
Listing 6.132 Use of toString() Method
<html> <body> <script lanuguage="JavaScript"> <!–– Hide // function just writes some text output function writeText(){ document.write("Some dummy text"); } // Call the toString() method var func = writeText.toString(); // ... |
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.