aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/global_objects/string/trimstart
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/javascript/reference/global_objects/string/trimstart
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/string/trimstart')
-rw-r--r--files/ja/web/javascript/reference/global_objects/string/trimstart/index.html116
1 files changed, 116 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/string/trimstart/index.html b/files/ja/web/javascript/reference/global_objects/string/trimstart/index.html
new file mode 100644
index 0000000000..b7c5a6210c
--- /dev/null
+++ b/files/ja/web/javascript/reference/global_objects/string/trimstart/index.html
@@ -0,0 +1,116 @@
+---
+title: String.prototype.trimStart()
+slug: Web/JavaScript/Reference/Global_Objects/String/trimStart
+tags:
+ - JavaScript
+ - Method
+ - Prototype
+ - Reference
+ - String
+translation_of: Web/JavaScript/Reference/Global_Objects/String/trimStart
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>trimStart()</code></strong> メソッドは、文字列の先頭のホワイトスペースを削除します。 <code>trimLeft()</code> はこのメソッドのエイリアスです。</p>
+
+<div>{{EmbedInteractiveExample("pages/js/string-trimstart.html")}}</div>
+
+<div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div>
+
+<h2 id="Syntax" name="Syntax">構文</h2>
+
+<pre class="syntaxbox notranslate"><var>str</var>.trimStart();
+<var>str</var>.trimLeft();</pre>
+
+<h3 id="Return_value" name="Return_value">返値</h3>
+
+<p>呼び出した文字列から先頭 (左端) からホワイトスペースを削除した新しい文字列です。</p>
+
+<h2 id="Description" name="Description">解説</h2>
+
+<p><code>trimStart()</code> と <code>trimLeft()</code> メソッドは、左端のホワイトスペースを取り除いた文字列を返します。 <code>trimLeft()</code> または <code>trimStart()</code> は元の文字列自身の値に影響を与えません。</p>
+
+<h3 id="Aliasing" name="Aliasing">エイリアス</h3>
+
+<p>{{jsxref("String.prototype.padStart")}} のような関数との一貫性を持たせるため、標準メソッドの名前は <code>trimStart</code> となっています。しかし、ウェブの互換性の観点から、 <code>trimLeft</code> が <code>trimStart</code> のエイリアスとして残されます。エンジンによっては、以下のように解釈されます。</p>
+
+<pre class="brush: js notranslate">String.prototype.trimLeft.name === "trimStart";</pre>
+
+<h2 id="Examples" name="Examples">例</h2>
+
+<h3 id="Using_trimStart" name="Using_trimStart">trimStart() の使用</h3>
+
+<p>以下の例では、小文字の文字列 <code>'foo  '</code> を表示します。</p>
+
+<pre class="brush: js; highlight: [5] notranslate">var str = ' foo ';
+
+console.log(str.length); // 8
+
+str = str.trimStart();
+console.log(str.length); // 5
+console.log(str); // 'foo '
+</pre>
+
+<h2 id="ポリフィル">ポリフィル</h2>
+
+<pre class="brush: js; highlight: [5] notranslate">//https://github.com/FabioVergani/js-Polyfill_String-trimStart
+
+(function(w){
+    var String=w.String, Proto=String.prototype;
+
+    (function(o,p){
+        if(p in o?o[p]?false:true:true){
+            var r=/^\s+/;
+            o[p]=o.trimLeft||function(){
+                return this.replace(r,'')
+            }
+        }
+    })(Proto,'trimStart');
+
+})(window);
+
+
+/*
+ES6:
+(w=&gt;{
+    const String=w.String, Proto=String.prototype;
+
+    ((o,p)=&gt;{
+        if(p in o?o[p]?false:true:true){
+            const r=/^\s+/;
+            o[p]=o.trimLeft||function(){
+                return this.replace(r,'')
+            }
+        }
+    })(Proto,'trimStart');
+
+})(window);
+*/</pre>
+
+<h2 id="Specifications" name="Specifications">仕様書</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">仕様書</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-string.prototype.trimstart', ' String.prototype.trimStart')}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
+
+<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div>
+
+<p>{{Compat("javascript.builtins.String.trimStart")}}</p>
+
+<h2 id="See_also" name="See_also">関連情報</h2>
+
+<ul>
+ <li>{{jsxref("String.prototype.trim()")}}</li>
+ <li>{{jsxref("String.prototype.trimEnd()")}}</li>
+</ul>