mozilla

Revision 87729 of String.prototype.toString()

  • Revision slug: JavaScript/Reference/Global_Objects/String/toString
  • Revision title: toString
  • Revision id: 87729
  • Created:
  • Creator: evilpie
  • Is current revision? No
  • Comment 7 words added, 4 words removed

Revision Content

 

Summary

Returns a string representing the specified object.

Method of String
Implemented in: JavaScript 1.1
ECMAScript Edition: ECMA-262 1st Edition

Syntax

string.toString()

Parameters

None.

Description

The String object overrides the toString method of the Object object; it does not inherit Object.toString. For String objects, the toString method returns a string representation of the object.

Examples

Example: Using toString

The following example displays the string value of a String object:

x = new String("Hello world");
alert(x.toString())      // Displays "Hello world"

See also

Object.toString

 

{{ languages( { "es": "es/Referencia_de_JavaScript_1.5/Objetos_globales/String/toString", "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/String/toString", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/String/toString" } ) }}

Revision Source

<p> </p>
<h3 name="Summary">Summary</h3>
<p>Returns a string representing the specified object.</p>
<table class="fullwidth-table"> <tbody> <tr> <td class="header" colspan="2">Method of <a href="/En/Core_JavaScript_1.5_Reference/Global_Objects/String" title="En/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></td> </tr> <tr> <td>Implemented in:</td> <td>JavaScript 1.1</td> </tr> <tr> <td>ECMAScript Edition:</td> <td>ECMA-262 1st Edition</td> </tr> </tbody>
</table>
<h3 name="Syntax">Syntax</h3>
<p><code><em>string</em>.toString()</code></p>
<h3 name="Parameters">Parameters</h3>
<p>None.</p>
<h3 name="Description">Description</h3>
<p>The <code>String</code> object overrides the <code>toString</code> method of the <code><a href="/en/JavaScript/Reference/Global_Objects/Object" title="en/JavaScript/Reference/Global_Objects/Object">Object</a></code> object; it does not inherit <code><a href="/en/JavaScript/Reference/Global_Objects/Object/toString" title="en/JavaScript/Reference/Global_Objects/Object/toString">Object.toString</a></code>. For <code>String</code> objects, the <code>toString</code> method returns a string representation of the object.</p>
<h3 name="Examples">Examples</h3>
<h4 name="Example:_Using_toString">Example: Using <code>toString</code></h4>
<p>The following example displays the string value of a String object:</p>
<pre>x = new String("Hello world");
alert(x.toString())      // Displays "Hello world"
</pre>
<h3 name="See_also">See also</h3>
<p><a href="/en/JavaScript/Reference/Global_Objects/Object/toString" title="en/JavaScript/Reference/Global_Objects/Object/toString">Object.toString</a></p>
<p> </p>

<p>{{ languages( { "es": "es/Referencia_de_JavaScript_1.5/Objetos_globales/String/toString", "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/String/toString", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/String/toString" } ) }}</p>
Revert to this revision