目录

toSource()

描述 (Description)

此方法返回表示对象源代码的字符串。

Note - 此方法可能与所有浏览器不兼容。

语法 (Syntax)

toSource()方法的以下语法。

Date.toSource ()

返回值 (Return Value)

  • 对于内置Date对象,toSource返回一个字符串(new Date(...)),表示源代码不可用

  • 对于Date的实例,toSource返回表示源代码的字符串。

例子 (Example)

请尝试以下示例。

<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>

输出 (Output)

Formated Date : (new Date(743850547000))
↑回到顶部↑
WIKI教程 @2018