aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/string/trim/index.md
diff options
context:
space:
mode:
Diffstat (limited to 'files/ko/web/javascript/reference/global_objects/string/trim/index.md')
-rw-r--r--files/ko/web/javascript/reference/global_objects/string/trim/index.md95
1 files changed, 95 insertions, 0 deletions
diff --git a/files/ko/web/javascript/reference/global_objects/string/trim/index.md b/files/ko/web/javascript/reference/global_objects/string/trim/index.md
new file mode 100644
index 0000000000..32c3607a1f
--- /dev/null
+++ b/files/ko/web/javascript/reference/global_objects/string/trim/index.md
@@ -0,0 +1,95 @@
+---
+title: String.prototype.trim()
+slug: Web/JavaScript/Reference/Global_Objects/String/Trim
+tags:
+ - ECMAScript 5
+ - JavaScript
+ - Method
+ - Prototype
+ - Reference
+ - String
+translation_of: Web/JavaScript/Reference/Global_Objects/String/Trim
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>trim()</code></strong> 메서드는 문자열 양 끝의 공백을 제거합니다. 공백이란 모든 공백문자(space, tab, NBSP 등)와 모든 개행문자(LF, CR 등)를 의미합니다.</p>
+
+<div>{{EmbedInteractiveExample("pages/js/string-trim.html")}}</div>
+
+
+
+<h2 id="구문">구문</h2>
+
+<pre class="syntaxbox"><var>str</var>.trim()</pre>
+
+<h3 id="반환_값">반환 값</h3>
+
+<p>양 끝에서 공백을 제거한 새로운 문자열.</p>
+
+<h2 id="설명">설명</h2>
+
+<p><code>trim()</code> 메서드는 양끝의 공백을 제거한 문자열을 반환합니다. <code>trim()</code>은 원본 문자열에는 영향을 주지 않습니다. </p>
+
+<h2 id="예제">예제</h2>
+
+<h3 id="trim()_사용"><code>trim()</code> 사용</h3>
+
+<p>아래의 예제는 소문자 문자열  <code>'foo'</code>를 표시합니다.</p>
+
+<pre class="brush: js">var orig = ' foo ';
+console.log(orig.trim()); // 'foo'
+
+// 한 쪽의 공백만 제거하는 .trim() 예제
+
+var orig = 'foo ';
+console.log(orig.trim()); // 'foo'
+</pre>
+
+<h2 id="폴리필">폴리필</h2>
+
+<p>다른 코드 전에 아래 코드를 실행하면 지원하지 않는 환경에서도  <code>String.trim()</code> 을 사용할 수 있습니다.</p>
+
+<pre class="brush: js">if (!String.prototype.trim) {
+  String.prototype.trim = function () {
+  return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
+ };
+}
+</pre>
+
+<h2 id="명세">명세</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">표준</th>
+ <th scope="col">상태</th>
+ <th scope="col">비고</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.5.4.20', 'String.prototype.trim')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td>Initial definition. Implemented in JavaScript 1.8.1.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-string.prototype.trim', 'String.prototype.trim')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-string.prototype.trim', 'String.prototype.trim')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="브라우저_호환성">브라우저 호환성</h2>
+
+<p>{{Compat("javascript.builtins.String.trim")}}</p>
+
+<h2 id="참조">참조</h2>
+
+<ul>
+ <li>{{jsxref("String.prototype.trimLeft()")}} {{non-standard_inline}}</li>
+ <li>{{jsxref("String.prototype.trimRight()")}} {{non-standard_inline}}</li>
+</ul>