描述
此方法返回一个字符串,该字符串表示对象的源代码。
注意 − 此方法可能并非与所有浏览器都兼容。
语法
toSource () 方法的以下语法。
Date.toSource ()
返回值
- 对于内置的 Date 对象,toSource 返回一个字符串 (new Date(...))表示源码不可用
- 对于 Date 的实例,toSource 返回表示源代码的字符串。
请尝试以下示例。
<html>
<head>
<title>JavaScript toSource Method</title>
</head>
<body>
<script type = "text/javascript">
var dt = new Date(1993, 6, 28, 14, 39, 7);
document.write( "Formated Date : " + dt.toSource() );
</script>
</body>
</html>
输出
Formated Date : (new Date(743850547000))