aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/string/tosource/index.html
blob: 756758d87731f04037837fc71cf058c8c9c6a394 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
title: String.prototype.toSource()
slug: Web/JavaScript/Reference/Global_Objects/String/toSource
translation_of: Web/JavaScript/Reference/Global_Objects/String/toSource
---
<div>{{JSRef}} {{non-standard_header}}</div>

<p><strong><code>toSource()</code></strong> 方法返回一个代表对象的源代码。</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox"><code>String.toSource()
<var>str</var>.toSource()
</code></pre>

<h2 id="描述">描述</h2>

<p><code>toSource()</code> 方法返回以下值:</p>

<p>对于内建对象 {{jsxref("String")}} , <code>toSource()返回以下值说明源码不可用:</code></p>

<pre class="brush: js">function String() {
    [native code]
}
</pre>

<p>对于实例{{jsxref("String")}} 或者字符串, <code>toSource()</code> 返回一个字符串表示源码.</p>

<p>这种方法通常在内部被JavaScript调用,而不是明确的代码。.</p>

<h2 id="规范">规范</h2>

<p>不属于任何标准. 在 JavaScript 1.3实现了.</p>

<h2 id="浏览器适配">浏览器适配</h2>

<div>{{CompatibilityTable}}</div>

<div>
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div>
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="参见">参见</h2>

<ul>
 <li>{{jsxref("Object.prototype.toSource()")}}</li>
</ul>