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