JavaScript Tutorial/Math/toSource
Версия от 18:52, 25 мая 2010; (обсуждение)
Math.toSource()
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>