Math.toSource() : toSource « Math « JavaScript Tutorial






The toSource() method creates a copy of the object.

It returns a string representation of an object, which can be passed to the eval method to create a copy of the object.

<html>
    <body>
    <script language="JavaScript">
    <!--
    function copy(){
        var result = Math.toSource(Math.E);
        document.form1.answer.value = result;
    }
    -->
    </script>
    <form name=form1>
    Click on the button to create a copy of a Math object.
    <br><br>
    <input type="button" value="Copy" onClick='copy()'>
    <br>
    The result of toSource is:
    <input type="text" name="answer" size=20>
    </form>
    </body>
    </html>








9.28.toSource
9.28.1.Math.toSource()