aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/symbol/tosource/index.html
blob: 56d7571d554aef70ec9529e1f8feceb7a2e46c98 (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
92
93
---
title: Symbol.prototype.toSource()
slug: Web/JavaScript/Reference/Global_Objects/Symbol/toSource
translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/toSource
---
<div>{{JSRef}} {{Non-standard_header}}</div>

<p><code><strong>toSource()</strong></code> 方法返回代表该对象源码的字符串。</p>

<p>该方法通常由JavaScript内部调用。</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox"><var>Symbol</var>.toSource()

var sym = Symbol()
sym.toSource()</pre>

<h2 id="Description">Description</h2>

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

<p>对于内建<code>Symbol对象</code>, <code>toSource</code> 返回以下字符串,表明源代码不可见:</p>

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

<p>对于<code>Symbol实例</code>, <code>toSource</code> 返回代表源码的字符串。</p>

<pre class="brush: js">"Symbol()"</pre>

<h2 id="Specifications">Specifications</h2>

<p>还未成为任何标准的一部分</p>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<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>{{CompatNo}}</td>
   <td>{{ CompatGeckoDesktop("36.0") }}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<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>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{ CompatGeckoMobile("36.0") }}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

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