aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/global_objects/string/padend/index.html
blob: 795c9dec4543ba29f1fee27e3d920a8aad9f9b4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
title: String.prototype.padEnd()
slug: Web/JavaScript/Reference/Global_Objects/String/padEnd
tags:
  - JavaScript
  - Method
  - Prototype
  - Reference
  - String
translation_of: Web/JavaScript/Reference/Global_Objects/String/padEnd
---
<div>{{JSRef}}</div>

<p><strong><code>padEnd()</code></strong> メソッドは、結果の文字列が指定した長さになるように、現在の文字列を他の文字列で (必要に応じて繰り返して) 延長します。延長は、現在の文字列の末尾から適用されます。</p>

<div>{{EmbedInteractiveExample("pages/js/string-padend.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>.padEnd(<var>targetLength</var> [, <var>padString</var>])</pre>

<h3 id="Parameters" name="Parameters">引数</h3>

<dl>
 <dt><code><var>targetLength</var></code></dt>
 <dd>現在の文字列の延長後に返される文字列の長さです。この値が現在の文字列の長さよりも短い場合、現在の文字列が返されます。</dd>
 <dt><code><var>padString</var></code> {{optional_inline}}</dt>
 <dd>現在の文字列を延長するための文字列です。この文字列が <code><var>targetLength</var></code> に収まらないほど長い場合は、左書きの言語では最も左の部分が、右書きの言語では最も右の部分が使用され、残りは切り捨てられます。この引数の既定値は、 "<code> </code>" (<code>U+0020</code> 空白) です。</dd>
</dl>

<h3 id="Return_value" name="Return_value">返値</h3>

<p>{{jsxref("String")}} で、 <code><var>targetLength</var></code> で指定された長さにするために、 <code><var>padString</var></code> を現在の <code><var>str</var></code> の末尾に適用したものです。</p>

<h2 id="Examples" name="Examples"></h2>

<h3 id="Using_padEnd" name="Using_padEnd">padEnd の使用</h3>

<pre class="brush: js notranslate">'abc'.padEnd(10);          // "abc       "
'abc'.padEnd(10, "foo");   // "abcfoofoof"
'abc'.padEnd(6, "123456"); // "abc123"
'abc'.padEnd(1);           // "abc"</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.padend', 'String.prototype.padEnd')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>

<p>{{Compat("javascript.builtins.String.padEnd")}}</p>

<h2 id="See_also" name="See_also">関連情報</h2>

<ul>
 <li>{{jsxref("String.prototype.padStart()")}}</li>
</ul>