Javascript Boolean.toSource()方法

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

 


上一篇: JavaScript Boolean.constructor()方法 下一篇: Javascript Boolean.toString()方法