Bản dịch này chưa hoàn thành. Xin hãy giúp dịch bài viết này từ tiếng Anh
Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
Phương pháp toSource() trả về một chuỗi đại diện cho mã nguồn của đối tượng.
Cú pháp
function.toSource();
Giá trị trả về
Một chuỗi đại diện cho mã nguồn của đối tượng.
Mô tả
Phương pháp toSource trả về các giá trị theo
- Đối với đối tượng tích hợp
Function,toSource()trả về chuỗi mã nguồn không khả dụng:function Function() { [native code] } - Đối với các hàm tùy chỉnh,
toSource()trả về nguồn Javascript định nghĩa đối tượng dưới dạng chuỗi.// For example: function hello() { console.log("Hello, World!"); } hello.toSource();// Results in: "function hello() { console.log(\"Hello, World!\"); }"
Phương pháp này thường được gọi cục bộ trong Javascript và không rõ ràng bằng mã. Bạn có thể gọi toSource() trong khi gỡ lỗi để kiểm tra nội dung của một đối tượng.
Đặc điểm chi tiết
Không phải là một đặc tính chuẩn nào. Ghi rõ trong JavaScript 1.3.
Trình duyệt tương thích
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toSource | Chrome No support No | Edge No support No | Firefox
No support
1 — 74
| IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Firefox Android Full support 4 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No |
Legend
- Full support
- Full support
- No support
- No support
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.
- See implementation notes.
- See implementation notes.