aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/string/trimend/index.html
blob: a66524556bd2208b6e4751be5e0cc447614becee (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
70
71
72
---
title: String.prototype.trimEnd()
slug: Web/JavaScript/Reference/Global_Objects/String/trimEnd
tags:
- JavaScript
- Method
- Prototype
- Reference
- String
- Polyfill
browser-compat: javascript.builtins.String.trimEnd
translation_of: Web/JavaScript/Reference/Global_Objects/String/trimEnd
---
<div>{{JSRef}}</div>

<p><strong><code>trimEnd()</code></strong>메서드는 문자열 끝부분의 공백을 제거합니다.
또 해당 메서드는<code>trimRight()</code>라는 별칭으로 호출이 가능합니다.</p>

<div>{{EmbedInteractiveExample("pages/js/string-trimend.html")}}</div>


<h2 id="syntax">구문</h2>

<pre class="brush: js">
trimEnd()

trimRight()
</pre>

<h3 id="return_value">반환값</h3>

<p><code><var>str</var></code>에서 (오른쪽)끝 공백이 제거된 새 문자열을 반환합니다.</p>

<p><code><var>str</var></code>에 공백이 없을시에도 에러가 발생하지 않고 여전히 새 문자열(본질적으로 <code><var>str</var></code>의 복사본)이 반환됩니다.</p>

<h3 id="aliasing">별칭</h3>

<p>{{jsxref("String.prototype.padEnd")}}표준 메서드 이름과 같은 함수의 일관성을 위해서<code>trimEnd</code>가 되었습니다. 그러나,
    웹 호환성을 위해서 <code>trimEnd</code><code>trimRight</code>이라는 별칭을 가집니다. 일부 엔진에서 이것은 다음 예시를 의미합니다.</p>

<pre class="brush: js">String.prototype.trimRight.name === "trimEnd";</pre>

<h2 id="examples">예제</h2>

<h3 id="using_trimEnd">trimEnd() 사용</h3>

<p>다음 예제는 <code>'   foo'</code> 문자열을 표시합니다.</p>

<pre class="brush: js highlight: [5]">var str = '   foo  ';

console.log(str.length); // 8

str = str.trimEnd();
console.log(str.length); // 6
console.log(str);        // '   foo'
</pre>

<h2 id="specifications">명세</h2>

{{Specifications}}

<h2 id="browser_compatibility">브라우저 호환성</h2>

<p>{{Compat}}</p>

<h2 id="see_also">같이 보기</h2>

<ul>
  <li><code>String.prototype.trimEnd</code>의 폴리필은 여기를<a href="https://github.com/zloirock/core-js#ecmascript-string-and-regexp"><code>core-js</code></a></li>
  <li>{{jsxref("String.prototype.trim()")}}</li>
  <li>{{jsxref("String.prototype.trimStart()")}}</li>
</ul>