此方法返回表示对象的字符串,注意-此方法可能与所有浏览器不兼容。

toSource() - 语法

Date.toSource ()
  • 对于内置的Date对象,toSource返回一个字符串(new date(.))

  • 对于Date,toSource返回表示源字符串。

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

参考链接

https://www.learnfk.com/javascript/date-tosource.html