mozilla

Compare Revisions

String.prototype.trim()

Change Revisions

Revision 43456:

Revision 43456 by evilpie on

Revision 43457:

Revision 43457 by Nesk on

Title:
Trim
Trim
Slug:
JavaScript/Reference/Global_Objects/String/Trim
JavaScript/Reference/Global_Objects/String/Trim
Tags:
"String Methods"
"String Methods"
Content:

Revision 43456
Revision 43457
n79        <a class="internal" href="/en/JavaScript/Reference/Globaln79        <a class="internal" href="/en/JavaScript/Reference/Global
>_Objects/String/TrimLeft" title="en/Core JavaScript 1.5 Reference>_Objects/String/TrimLeft" title="en/Core JavaScript 1.5 Reference
>/Global Objects/String/trimLeft"><code>trimLeft()</code></a>&nbsp>/Global Objects/String/trimLeft"><code>trimLeft()</code></a>
>; 
nn85    <h2 name="See_also">
86      Compatibility
87    </h2>
88    <p>
89      Running the following code before any other code will creat
 >e <code>String.trim</code> if it's not natively available.
90    </p>
91    <pre class="deki-transform">
92if(!String.prototype.trim) {
93  String.prototype.trim = function () {
94    return this.replace(/^\s+|\s+$/g,'');
95  };
96}
97</pre>
t89      Based on <a class=" external" href="http://kangax.github.cot102      Based on <a class="external" href="http://kangax.github.com
>m/es5-compat-table/">Kangax's compat tables</a>>/es5-compat-table/">Kangax's compat tables</a>

Back to History