mozilla

Compare Revisions

String.prototype.toString()

Change Revisions

Revision 417787:

Revision 417787 by Sheppy on

Revision 509843:

Revision 509843 by fscholz on

Title:
String.toString
String.prototype.toString()
Slug:
Web/JavaScript/Reference/Global_Objects/String/toString
Web/JavaScript/Reference/Global_Objects/String/toString
Tags:
"String", "String Methods"
"String", "Method", "JavaScript", "prototype"
Content:

Revision 417787
Revision 509843
nn7    <div>
8      {{JSRef("Global_Objects", "Object")}}
9    </div>
n11      Returns a string representing the specified object.n14      The <code><strong>toString()</strong></code> method returns
 > a string representing the specified object.
n13    <table class="standard-table">n
14      <thead>
15        <tr>
16          <th class="header" colspan="2">
17            Method of <a href="/en-US/docs/JavaScript/Reference/G
>lobal_Objects/String"><code>String</code></a> 
18          </th>
19        </tr>
20      </thead>
21      <tbody>
22        <tr>
23          <td>
24            Implemented in
25          </td>
26          <td>
27            JavaScript 1.1
28          </td>
29        </tr>
30        <tr>
31          <td>
32            ECMAScript Edition
33          </td>
34          <td>
35            ECMAScript 1st Edition
36          </td>
37        </tr>
38      </tbody>
39    </table>
n44<code><em>string</em>.toString()</code>n20<code><em>str</em>.toString()</code>
n46    <h3 id="Parameters" name="Parameters">n
47      Parameters
48    </h3>
49    <p>
50      None.
51    </p>
n56      The <code>String</code> object overrides the <code>toStringn26      The <code>String</code> object overrides the <code>toString
></code> method of the <a href="/en-US/docs/JavaScript/Reference/G></code> method of the {{jsxref("Global_Objects/Object", "Object")
>lobal_Objects/Object" title="JavaScript/Reference/Global_Objects/>}} object; it does not inherit {{jsxref("Object.toString()")}}. F
>Object"><code>Object</code></a> object; it does not inherit <a hr>or <code>String</code> objects, the <code>toString</code> method 
>ef="/en-US/docs/JavaScript/Reference/Global_Objects/Object/toStri>returns a string representation of the object and is the same as 
>ng" title="JavaScript/Reference/Global_Objects/Object/toString"><>the {{jsxref("String.prototype.valueOf()")}} method.
>code>Object.toString</code></a>. For <code>String</code> objects, 
> the <code>toString</code> method returns a string representation 
> of the object. 
nn42    <h2 id="Specifications">
43      Specifications
44    </h2>
45    <table class="standard-table">
46      <tbody>
47        <tr>
48          <th scope="col">
49            Specification
50          </th>
51          <th scope="col">
52            Status
53          </th>
54          <th scope="col">
55            Comment
56          </th>
57        </tr>
58        <tr>
59          <td>
60            ECMAScript 1st Edition.
61          </td>
62          <td>
63            Standard
64          </td>
65          <td>
66            Initial definition.<br>
67            Implemented in JavaScript 1.1.
68          </td>
69        </tr>
70        <tr>
71          <td>
72            {{SpecName('ES5.1', '#sec-15.5.4.2', 'String.prototyp
 >e.toString')}}
73          </td>
74          <td>
75            {{Spec2('ES5.1')}}
76          </td>
77          <td>
78            &nbsp;
79          </td>
80        </tr>
81        <tr>
82          <td>
83            {{SpecName('ES6', '#sec-string.prototype.tostring', '
 >String.prototype.toString')}}
84          </td>
85          <td>
86            {{Spec2('ES6')}}
87          </td>
88          <td>
89            &nbsp;
90          </td>
91        </tr>
92      </tbody>
93    </table>
94    <h2 id="Browser_compatibility">
95      Browser compatibility
96    </h2>
97    <p>
98      {{ CompatibilityTable() }}
99    </p>
100    <div id="compat-desktop">
101      <table class="compat-table">
102        <tbody>
103          <tr>
104            <th>
105              Feature
106            </th>
107            <th>
108              Chrome
109            </th>
110            <th>
111              Firefox (Gecko)
112            </th>
113            <th>
114              Internet Explorer
115            </th>
116            <th>
117              Opera
118            </th>
119            <th>
120              Safari
121            </th>
122          </tr>
123          <tr>
124            <td>
125              Basic support
126            </td>
127            <td>
128              {{ CompatVersionUnknown() }}
129            </td>
130            <td>
131              {{ CompatVersionUnknown() }}
132            </td>
133            <td>
134              {{ CompatVersionUnknown() }}
135            </td>
136            <td>
137              {{ CompatVersionUnknown() }}
138            </td>
139            <td>
140              {{ CompatVersionUnknown() }}
141            </td>
142          </tr>
143        </tbody>
144      </table>
145    </div>
146    <div id="compat-mobile">
147      <table class="compat-table">
148        <tbody>
149          <tr>
150            <th>
151              Feature
152            </th>
153            <th>
154              Android
155            </th>
156            <th>
157              Chrome for Android
158            </th>
159            <th>
160              Firefox Mobile (Gecko)
161            </th>
162            <th>
163              IE Mobile
164            </th>
165            <th>
166              Opera Mobile
167            </th>
168            <th>
169              Safari Mobile
170            </th>
171          </tr>
172          <tr>
173            <td>
174              Basic support
175            </td>
176            <td>
177              {{ CompatVersionUnknown() }}
178            </td>
179            <td>
180              {{ CompatVersionUnknown() }}
181            </td>
182            <td>
183              {{ CompatVersionUnknown() }}
184            </td>
185            <td>
186              {{ CompatVersionUnknown() }}
187            </td>
188            <td>
189              {{ CompatVersionUnknown() }}
190            </td>
191            <td>
192              {{ CompatVersionUnknown() }}
193            </td>
194          </tr>
195        </tbody>
196      </table>
197    </div>
tt202      <li>{{jsxref("Object.prototype.toSource()")}}
76      <li>203      </li>
77        <a href="/en-US/docs/JavaScript/Reference/Global_Objects/204      <li>{{jsxref("String.prototype.valueOf()")}}
>Object/toString" title="JavaScript/Reference/Global_Objects/Objec 
>t/toString">Object.toString</a> 

Back to History