---
title: Array.prototype.toSource()
slug: Web/JavaScript/Reference/Global_Objects/Array/toSource
translation_of: Web/JavaScript/Reference/Global_Objects/Array/toSource
---
<p>{{JSRef("Global_Objects", "Array")}}{{Non-standard_header}}</p>

<h2 id="Summary" name="Summary">概述</h2>

<p>返回一个字符串,代表该数组的源代码.</p>

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

<pre class="syntaxbox"><code><em>array</em>.toSource()</code></pre>

<h3 id="Parameters" name="Parameters">参数</h3>

<p>无</p>

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

<p>在调试时,你可以使用<code>toSource方法</code>来查看一个数组的内容.</p>

<h2 id="Examples" name="Examples">例子</h2>

<h3 id="Example:_Examining_the_source_code_of_an_array" name="Example:_Examining_the_source_code_of_an_array">例子: 查看数组的源码</h3>

<pre class="brush:js">var alpha = new Array("a", "b", "c");

alpha.toSource();   //返回["a", "b", "c"]</pre>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p>{{Compat("javascript.builtins.Array.toSource")}}</p>

<h2 id="See_also" name="See_also">相关链接</h2>

<ul>
 <li><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Array/toString" title="JavaScript/Reference/Global_Objects/Array/toString">Array.toString</a></li>
</ul>