
- ES6 教程
- ES6 - 主頁
- ES6 - 概覽
- ES6 - 環境
- ES6 - 語法
- ES6 - 變數
- ES6 - 運算子
- ES6 - 決策
- ES6 - 迴圈
- ES6 - 函式
- ES6 - 事件
- ES6 - Cookie
- ES6 - 頁面重定向
- ES6 - 對話方塊
- ES6 - void 關鍵字
- ES6 - 頁面列印
- ES6 - 物件
- ES6 - 數字
- ES6 - 布林值
- ES6 - 字串
- ES6 - 符號
- ES6 - 新字串方法
- ES6 - 陣列
- ES6 - 日期
- ES6 - 數學
- ES6 - 正則表示式
- ES6 - HTML DOM
- ES6 - 迭代器
- ES6 - 集合
- ES6 - 類
- ES6 - Map 和 Set
- ES6 - Promise
- ES6 - 模組
- ES6 - 錯誤處理
- ES6 - 物件擴充套件
- ES6 - Reflect API
- ES6 - Proxy API
- ES6 - 驗證
- ES6 - 動畫
- ES6 - 多媒體
- ES6 - 除錯
- ES6 - 影像對映
- ES6 - 瀏覽器
- ES7 - 新特性
- ES8 - 新特性
- ES9 - 新特性
- ES6 有用資源
- ES6 - 快速指南
- ES6 - 有用資源
- ES6 - 討論
ES6 - toSource()
javascript boolean toSource() 方法返回一個表示物件原始碼的字串。
注意 - 此方法並不適用於所有瀏覽器。
以下是此方法的語法。
boolean.toSource()
示例
<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() is : "+ newBook.toSource()); </script> </body> </html>
成功執行上述程式碼後會顯示以下輸出。
({title:"Perl", publisher:"Leo Inc", price:200})
廣告