目录

toSource()

描述 (Description)

Javascript boolean toSource()方法返回表示对象源代码的字符串。

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

语法 (Syntax)

其语法如下 -

boolean.toSource()

返回值 (Return Value)

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

例子 (Example)

请尝试以下示例。

<html>
   <head>
      <title>JavaScript toSource() Method</title>
   </head>
   <body>
      <script type="text/javascript">
         function book(title, publisher, price)
         {
            this.title = title;
            this.publisher = publisher;
            this.price = price;
         }
         var newBook = new book("Perl","Leo Inc",200); 
         document.write(newBook.toSource()); 
      </script>
   </body>
</html>

输出 (Output)

({title:"Perl", publisher:"Leo Inc", price:200})
↑回到顶部↑
WIKI教程 @2018