89 lines
4.0 KiB
HTML

<article id="wikiArticle">
<div>
<div class="blockIndicator nonStandard nonStandardHeader">
<p><strong><span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span> 非标准</strong><br/>
该特性是非标准的,请尽量不要在生产环境中使用它!</p>
</div></div>
<h2 id="Summary" name="Summary">概述</h2>
<p><code><strong>toSource()</strong></code> 方法返回该对象源码的字符串表示。</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre><code class="language-javascript">numObj.toSource();
Number.toSource();
</code></pre>
<h3 id="Parameters" name="Parameters">参数</h3>
<p></p>
<h2 id="Description" name="Description">描述</h2>
<p><code>toSource()</code> 方法返回下列值:</p>
<ul>
<li>对于内置 <code>Number</code> 对象, <code>toSource()</code> 返回下面字符串,用来指明源码是不可见的。</li>
</ul>
<pre class="eval">function Number() { [native code] }</code></pre>
<ul>
<li>对于 <code>Number</code> 对象的实例,<code>toSource()</code> 返回一个表示源码的字符串。</li>
</ul>
<p>该方法通常被 JavaScript 内部调用,而不是在代码中显示调用。</p>
<h2 id="规范">规范</h2>
<p>不是任何标准的一部分。在 JavaScript 1.3 被实现。</p>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p></p><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div><p></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><span style="color: rgb(255, 153, 0);" title="Compatibility unknown; please update this.">?</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: rgb(255, 153, 0);" title="Compatibility unknown; please update this.">?</span></td>
<td><span style="color: rgb(255, 153, 0);" title="Compatibility unknown; please update this.">?</span></td>
<td><span style="color: rgb(255, 153, 0);" title="Compatibility unknown; please update this.">?</span></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><span style="color: rgb(255, 153, 0);" title="Compatibility unknown; please update this.">?</span></td>
<td><span style="color: rgb(255, 153, 0);" title="Compatibility unknown; please update this.">?</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: rgb(255, 153, 0);" title="Compatibility unknown; please update this.">?</span></td>
<td><span style="color: rgb(255, 153, 0);" title="Compatibility unknown; please update this.">?</span></td>
<td><span style="color: rgb(255, 153, 0);" title="Compatibility unknown; please update this.">?</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="See_Also" name="See_Also">相关链接</h2>
<ul>
<li><a href="Reference/Global_Objects/Object/toSource" title="toSource()方法返回一个表示对象源代码的字符串。"><code>Object.prototype.toSource()</code></a></li>
</ul>
</article>