String.prototype.trimLeft()

  • Revision slug: JavaScript/Reference/Global_Objects/String/TrimLeft
  • Revision title: trimLeft
  • Revision id: 43476
  • Created:
  • Creator: ziyunfei
  • Is current revision? No
  • Comment 18 words added

Revision Content

{{ Non-standard_header() }}

Summary

Removes whitespace from the left end of the string.

Method of String
Implemented in JavaScript 1.8.1
ECMAScript Edition None

Syntax

string.trimLeft()

Parameters

None.

Description

The trimLeft method returns the string stripped of whitespace from its left end. trimLeft does not affect the value of the string itself.

Examples

Example: Using trimLeft

The following example displays the lowercase string "foo  ":

var orig="   foo  "
document.write(orig.trimLeft())

See Also

{{ languages( { "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/String/TrimLeft", "zh-cn": "zh-cn/Core_JavaScript_1.5_Reference/Global_Objects/String/TrimLeft"} ) }}

Revision Source

<p>{{ Non-standard_header() }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>Removes whitespace from the left end of the string.</p>
<table class="standard-table"> <thead> <tr> <th class="header" colspan="2">Method of <a href="/en/JavaScript/Reference/Global_Objects/String" title="en/JavaScript/Reference/Global_Objects/String"><code>String</code></a></th> </tr> </thead> <tbody> <tr> <td>Implemented in</td> <td>JavaScript 1.8.1</td> </tr> <tr> <td>ECMAScript Edition</td> <td>None</td> </tr> </tbody>
</table>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<p><code><em>string</em>.trimLeft()</code></p>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<p>None.</p>
<h3 id="Description" name="Description">Description</h3>
<p>The <code>trimLeft</code> method returns the string stripped of whitespace from its left end. <code>trimLeft</code> does not affect the value of the string itself.</p>
<h3 id="Examples" name="Examples">Examples</h3>
<h4 id="Example:_Using_toLowerCase" name="Example:_Using_toLowerCase">Example: Using <code>trimLeft</code></h4>
<p>The following example displays the lowercase string "foo  ":</p>
<pre>var orig="   foo  "
document.write(orig.trimLeft())
</pre>
<h3 id="See_Also" name="See_Also">See Also</h3>
<ul> <li><a class="internal" href="/en/JavaScript/Reference/Global_Objects/String/Trim" title="en/Core JavaScript 1.5 Reference/Global Objects/String/trim"><code>trim()</code></a></li> <li><a class="internal" href="/en/JavaScript/Reference/Global_Objects/String/TrimRight" title="en/Core JavaScript 1.5 Reference/Global Objects/String/trimRight"><code>trimRight()</code></a></li>
</ul>
<p>{{ languages( { "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/String/TrimLeft", "zh-cn": "zh-cn/Core_JavaScript_1.5_Reference/Global_Objects/String/TrimLeft"} ) }}</p>
Revert to this revision