Array.prototype.toSource()

  • Revision slug: JavaScript/Reference/Global_Objects/Array/toSource
  • Revision title: Array toSource method
  • Revision id: 310683
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

{{ Non-standard_header() }}

Summary

Returns a string representing the source code of the array.

Method of Array
Implemented in JavaScript 1.3
ECMAScript Edition none

Syntax

array.toSource()

Parameters

None.

Description

The toSource method returns the following values:

  • For the built-in Array object, toSource returns the following string indicating that the source code is not available:
function Array() {
    [native code]
}
  • For instances of Array, toSource returns a string representing the source code.

This method is usually called internally by JavaScript and not explicitly in code. You can call toSource while debugging to examine the contents of an array.

Examples

Example: Examining the source code of an array

To examine the source code of an array:

alpha = new Array("a", "b", "c");
alpha.toSource();   //returns ["a", "b", "c"]

See Also

Revision Source

<div>{{ Non-standard_header() }}</div>



<h2 id="Summary" name="Summary">Summary</h2>
<p>Returns a string representing the source code of the array.</p>
<table class="standard-table">
  <thead>
    <tr>
      <th class="header" colspan="2">Method of <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Array"><code>Array</code></a></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Implemented in</td>
      <td>JavaScript 1.3</td>
    </tr>
    <tr>
      <td>ECMAScript Edition</td>
      <td>none</td>
    </tr>
  </tbody>
</table>



<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox"><code><em>array</em>.toSource()</code></pre>



<h3 id="Parameters" name="Parameters">Parameters</h3>
<p>None.</p>



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

<p>The <code>toSource</code> method returns the following values:</p>
<!-- This shouldn't be here, but until reorganization where pages are moved to their proper places, the title of this article is ambiguous, so it can stay. After reorganization, this should be removed. -->

<ul>
  <li>For the built-in <code>Array</code> object, <code>toSource</code> returns the following string indicating that the source code is not available:</li>
</ul>

<pre class="eval">
function Array() {
    [native code]
}
</pre>

<ul>
  <li>For instances of <code>Array</code>, <code>toSource</code> returns a string representing the source code.</li>
</ul>

<p>This method is usually called internally by JavaScript and not explicitly in code. You can call <code>toSource</code> while debugging to examine the contents of an array.</p>



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



<h3 id="Example:_Examining_the_source_code_of_an_array" name="Example:_Examining_the_source_code_of_an_array">Example: Examining the source code of an array</h3>

<p>To examine the source code of an array:</p>

<pre class="brush:js">alpha = new Array("a", "b", "c");
alpha.toSource();   //returns ["a", "b", "c"]</pre>



<h2 id="See_Also" name="See_Also">See Also</h2>
<ul>
<li><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Array/toString" title="JavaScript/Reference/Global_Objects/Array/toString">Array.toString</a></li>
</ul>



<!-- OLD DATA -->
<!-- languages( { "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Objets_globaux/Array/toSource" }) -->
Revert to this revision