Methods in Functions
Only a single standard method object is available at this time for functions. Several other browser-specific methods are available but, as noted previously, this book focuses primarily on those that can be used with any browser. The method converts the output of a function to a string using the toString() method. It can be added to any function object. This format changes all numeric or Boolean values to strings:
functionName.toString()
The following script provides an illustrative example of how the method works:
<html>
<head>
<title>Illustrating toString()</title>
<script language="JavaScript">
function alpha() { var hope = 12; var charity = 10; return hope > charity; } function beta() { var now = 57; var then = 3; ...
Get JavaScript Design 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.