Revision 87726 of String.prototype.toString()

  • Revision slug: JavaScript/Reference/Global_Objects/String/toString
  • Revision title: toString
  • Revision id: 87726
  • Created:
  • Creator: Ptak82
  • Is current revision? No
  • Comment pl

Revision Content

Summary

Returns a string representing the specified object.

Method of String
Implemented in: JavaScript 1.1, NES2.0
ECMA Version: ECMA-262

Syntax

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

{{ wiki.languages( { "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">String</a></td>
</tr>
<tr>
<td>Implemented in:</td>
<td>JavaScript 1.1, NES2.0</td>
</tr>
<tr>
<td>ECMA Version:</td>
<td>ECMA-262</td>
</tr>
</tbody></table>
<h3 name="Syntax"> Syntax </h3>
<p><code>
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/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></code> object; it does not inherit <code><a href="en/Core_JavaScript_1.5_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/Core_JavaScript_1.5_Reference/Global_Objects/Object/toString">Object.toString</a>
</p>{{ wiki.languages( { "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/String/toString" } ) }}
Revert to this revision