這篇文章主要介紹了簡介JavaScript中Boolean.toSource()方法的使用,是JS入門學習中的基礎知識,需要的朋友可以參考下
JavaScript Boolean.toSource()方法返回表示對象的源代碼的字符串。
注意:此方法不會在Internet Explorer中運行。
語法
- boolean.toSource()
下面是參數的詳細信息:
NA
返回值
返回表示對象的源代碼的字符串。
例子:
- <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>
這將產生以下結果:
- ({title:"Perl", publisher:"Leo Inc", price:200})
新聞熱點
疑難解答
圖片精選