JavaScript中toString()方法的使用詳解
更新時間:2015年06月05日 11:48:04 投稿:goldensun
這篇文章主要介紹了JavaScript中toString()方法的使用詳解,是JS入門學(xué)習(xí)中的基礎(chǔ)知識,需要的朋友可以參考下
JavaScript Boolean.toSource()方法返回表示對象的源代碼的字符串。
注意:此方法不會在Internet Explorer中運(yùn)行。
語法
boolean.toSource()
下面是參數(shù)的詳細(xì)信息:
- 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>
這將產(chǎn)生以下結(jié)果:
({title:"Perl", publisher:"Leo Inc", price:200})
相關(guān)文章
如何獲取JQUERY AJAX返回的JSON結(jié)果集實(shí)現(xiàn)代碼
我寫了個方法,用于查詢結(jié)果,但debug過程中發(fā)現(xiàn)結(jié)果集有數(shù)據(jù),我如何通過變量獲取呢2012-12-12