Compare Revisions

String.prototype.trim()

Change Revisions

Revision 498467:

Revision 498467 by mitar on

Revision 509865:

Revision 509865 by fscholz on

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

Revision 498467
Revision 509865
n8      {{js_minversion_header("1.8.1")}}n8      <div>
9        {{JSRef("Global_Objects", "String")}}
10      </div>
n14      Removes whitespace from both ends of the string.n16      The <code><strong>trim()</strong></code> method removes whi
 >tespace from both ends of the string.
n16    <table class="standard-table">n
17      <thead>
18        <tr>
19          <th class="header" colspan="2">
20            Method of <a href="/en-US/docs/JavaScript/Reference/G
>lobal_Objects/String" title="JavaScript/Reference/Global_Objects/ 
>String"><code>String</code></a> 
21          </th>
22        </tr>
23      </thead>
24      <tbody>
25        <tr>
26          <td>
27            Implemented in
28          </td>
29          <td>
30            JavaScript 1.8.1
31          </td>
32        </tr>
33        <tr>
34          <td>
35            ECMAScript Edition
36          </td>
37          <td>
38            ECMAScript 5th Edition
39          </td>
40        </tr>
41      </tbody>
42    </table>
n47<code><em>string</em>.trim()</code>n22<code><em>str</em>.trim()</code>
n49    <h3 id="Parameters" name="Parameters">n
50      Parameters
51    </h3>
52    <p>
53      None.
54    </p>
n73alert( orig.trim() );n42console.log( orig.trim() ); // "foo"
n76      Compatibilityn45      Polyfill
n88    <h2 id="Browser_compatibility" name="Browser_compatibility">n57    <h2>
58      Specifications
59    </h2>
60    <table class="standard-table">
61      <tbody>
62        <tr>
63          <th scope="col">
64            Specification
65          </th>
66          <th scope="col">
67            Status
68          </th>
69          <th scope="col">
70            Comment
71          </th>
72        </tr>
73        <tr>
74          <td>
75            {{SpecName('ES5.1', '#sec-15.5.4.20', 'String.prototy
 >pe.trim')}}
76          </td>
77          <td>
78            {{Spec2('ES5.1')}}
79          </td>
80          <td>
81            Initial definition.<br>
82            Implemented in JavaScript 1.8.1
83          </td>
84        </tr>
85        <tr>
86          <td>
87            {{SpecName('ES6', '#sec-string.prototype.trim', 'Stri
 >ng.prototype.trim')}}
88          </td>
89          <td>
90            {{Spec2('ES6')}}
91          </td>
92          <td>
93            &nbsp;
94          </td>
95        </tr>
96      </tbody>
97    </table>
98    <h2 id="Browser_compatibility">
n92      Based on <a href="http://kangax.github.com/es5-compat-tablen
>/">Kangax's compat tables</a> 
93    </p>
94    <div>
95      {{CompatibilityTable}}102      {{ CompatibilityTable() }}
96    </div>103    </p>
nn112              Chrome
113            </th>
114            <th>
n108              Chromen
109            </th>
110            <th>
n125              3.5n132              {{ CompatVersionUnknown() }}
126            </td>
127            <td>133            </td>
128              {{CompatVersionUnknown}}134            <td>
135              {{ CompatGeckoDesktop("3.5") }}
nn158              Android
159            </th>
160            <th>
161              Chrome for Android
162            </th>
163            <th>
n154              Androidn
155            </th>
156            <th>
n171              {{CompatUnknown}}n181              {{ CompatVersionUnknown() }}
172            </td>
173            <td>182            </td>
174              {{CompatUnknown}}
175            </td>183            <td>
184              {{ CompatVersionUnknown() }}
176            <td>185            </td>
177              {{CompatUnknown}}
178            </td>186            <td>
187              {{ CompatVersionUnknown() }}
179            <td>188            </td>
180              {{CompatUnknown}}
181            </td>189            <td>
190              {{ CompatVersionUnknown() }}
182            <td>191            </td>
192            <td>
183              {{CompatUnknown}}193              {{ CompatVersionUnknown() }}
194            </td>
195            <td>
196              {{ CompatVersionUnknown() }}
n189    <h2 id="See_also" name="See_also">n202    <h2 id="See_Also" name="See_Also">
n193      <li>n206      <li>{{jsxref("String.prototype.trimLeft()")}}
194        <a href="/en-US/docs/JavaScript/Reference/Global_Objects/
>String/trimLeft" title="JavaScript/Reference/Global Objects/Strin 
>g/trimLeft"><code>trimLeft()</code></a> 
t196      <li>t208      <li>{{jsxref("String.prototype.trimRight()")}}
197        <a href="/en-US/docs/JavaScript/Reference/Global_Objects/
>String/trimRight" title="JavaScript/Reference/Global Objects/Stri 
>ng/trimRight"><code>trimRight()</code></a> 

Back to History