diff options
author | Masahiro FUJIMOTO <mfujimot@gmail.com> | 2021-08-17 11:37:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-17 11:37:07 +0900 |
commit | 98a7793a51bdbdeefb172842e677dca22eb779e5 (patch) | |
tree | f07cde27678193afe366832bd58c958657fadc6c /files/ko/web/javascript/reference/global_objects/string | |
parent | 6c30dec8016abec2fba8caf0bd07d0e145c37caf (diff) | |
parent | a28f6c8632ced6d91d311614d96ab643e5ef7058 (diff) | |
download | translated-content-98a7793a51bdbdeefb172842e677dca22eb779e5.tar.gz translated-content-98a7793a51bdbdeefb172842e677dca22eb779e5.tar.bz2 translated-content-98a7793a51bdbdeefb172842e677dca22eb779e5.zip |
Merge branch 'mdn:main' into 20210811-orphaned/Web/API/NavigatorLanguage
Diffstat (limited to 'files/ko/web/javascript/reference/global_objects/string')
11 files changed, 187 insertions, 202 deletions
diff --git a/files/ko/web/javascript/reference/global_objects/string/concat/index.html b/files/ko/web/javascript/reference/global_objects/string/concat/index.html index 1d5b4f2cd6..170f8d2bc1 100644 --- a/files/ko/web/javascript/reference/global_objects/string/concat/index.html +++ b/files/ko/web/javascript/reference/global_objects/string/concat/index.html @@ -7,6 +7,7 @@ tags: - Prototype - Reference - String +browser-compat: javascript.builtins.String.concat translation_of: Web/JavaScript/Reference/Global_Objects/String/concat --- <div>{{JSRef}}</div> @@ -91,11 +92,7 @@ var greetList = ['Hello', ' ', 'Venkat', '!']; <h2 id="브라우저_호환성">브라우저 호환성</h2> -<p>{{Compat("javascript.builtins.String.concat")}}</p> - -<div></div> - -<div id="compat-mobile"></div> +<p>{{Compat}}</p> <h2 id="관련문서">관련문서</h2> diff --git a/files/ko/web/javascript/reference/global_objects/string/fromcharcode/index.html b/files/ko/web/javascript/reference/global_objects/string/fromcharcode/index.html index 98b1627666..9808f33355 100644 --- a/files/ko/web/javascript/reference/global_objects/string/fromcharcode/index.html +++ b/files/ko/web/javascript/reference/global_objects/string/fromcharcode/index.html @@ -51,7 +51,7 @@ String.fromCharCode(0x12014) // 숫자 '1'은 무시해서 "—" <h2 id="더_큰_값과_사용하기">더 큰 값과 사용하기</h2> -<p>초기 JavaScript 표준화 과정에서 예상했던 것처럼, 대부분의 흔한 유니코드 값을 16비트 숫자로 표현할 수 있고, <code>fromCharCode()</code>가 많은 흔한 값에서 하나의 문자를 반환할 수 있지만, <strong>모든</strong> 유효한 유니코드 값(최대 21비트)을 처리하려면 <code>fromCharCode()</code>만으로는 부족합니다. 높은 코드 포인트의 문자는 써로게이트<sup>surrogate</sup> 값 두 개를 합쳐 하나의 문자를 표현하므로,{{jsxref("String.fromCodePoint()")}}(ES2015 표준) 메서드는 그러한 쌍을 높은 값의 문자로 변환할 수 있습니다.</p> +<p>초기 JavaScript 표준화 과정에서 예상했던 것처럼, 대부분의 흔한 유니코드 값을 16비트 숫자로 표현할 수 있고, <code>fromCharCode()</code>가 많은 흔한 값에서 하나의 문자를 반환할 수 있지만, <strong>모든</strong> 유효한 유니코드 값(최대 21비트)을 처리하려면 <code>fromCharCode()</code>만으로는 부족합니다. 높은 코드 포인트의 문자는 써로게이트 값 두 개를 합쳐 하나의 문자를 표현하므로,{{jsxref("String.fromCodePoint()")}}(ES2015 표준) 메서드는 그러한 쌍을 높은 값의 문자로 변환할 수 있습니다.</p> <h2 id="명세">명세</h2> diff --git a/files/ko/web/javascript/reference/global_objects/string/index.html b/files/ko/web/javascript/reference/global_objects/string/index.html index 48217dee18..2f677292dc 100644 --- a/files/ko/web/javascript/reference/global_objects/string/index.html +++ b/files/ko/web/javascript/reference/global_objects/string/index.html @@ -12,7 +12,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String <p><strong><code>String</code></strong> 전역 객체는 문자열(문자의 나열)의 생성자입니다.</p> -<h2 id="Syntax" name="Syntax">구문</h2> +<h2 id="Syntax">구문</h2> <p>문자열 리터럴은 다음과 같은 형식을 사용합니다.</p> @@ -127,9 +127,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String <p>두 예시 모두 동일한 문자열을 생성합니다.</p> -<h2 id="Description" name="Description">설명</h2> +<h2 id="Description">설명</h2> -<p>문자열은 텍스트 형태로 표현될 수있는 데이터를 보관하는 데 유용합니다. 문자열에서 가장 많이 사용되는 작업들은 문자열의 길이를 확인하는 ({{jsxref("String.length", "length")}}), 문자열을 생성하고 연결하는 <a href="/ko/docs/Web/JavaScript/Reference/Operators/String_Operators" title="JavaScript/Reference/Operators/String_Operators">+ 와 += 문자열 연산자</a>, 서브문자열(substring)이 있는지 확인하고, 있으면 위치를 확인하는 {{jsxref("String.prototype.indexOf()", "indexOf()")}} 메서드, 서브문자열(substring)을 추출해내는 {{jsxref("String.prototype.substring()", "substring()")}} 메서드가 있습니다.</p> +<p>문자열은 텍스트 형태로 표현될 수있는 데이터를 보관하는 데 유용합니다. 문자열에서 가장 많이 사용되는 작업들은 문자열의 길이를 확인하는 ({{jsxref("String.length", "length")}}), 문자열을 생성하고 연결하는 <a href="/ko/docs/Web/JavaScript/Reference/Operators/String_Operators">+ 와 += 문자열 연산자</a>, 서브문자열(substring)이 있는지 확인하고, 있으면 위치를 확인하는 {{jsxref("String.prototype.indexOf()", "indexOf()")}} 메서드, 서브문자열(substring)을 추출해내는 {{jsxref("String.prototype.substring()", "substring()")}} 메서드가 있습니다.</p> <h3 id="문자_접근">문자 접근</h3> @@ -145,9 +145,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String <p>브라켓([ ]) 표기법을 사용하여 문자에 접근하는 경우 , 이러한 프로퍼티들에 새로운 값을 할당하거나 삭제할 수는 없습니다. 포함되어 있는 프로퍼티들은 작성할 수도, 수정할 수도 없습니다. (더 자세한 정보는 {{jsxref("Object.defineProperty()")}}를 참고 바랍니다 .)</p> -<h3 id="Comparing_strings" name="Comparing_strings">문자열 비교</h3> +<h3 id="Comparing_strings">문자열 비교</h3> -<p>C 개발자는 문자열 비교를 위하여 <code><span style="font-family: courier new,andale mono,monospace;">strcmp()</span></code> 함수를 사용합니다. JavaScript에서는 단지 <a href="/ko/docs/Web/JavaScript/Reference/Operators/Comparison_Operators" style="line-height: inherit;" title="JavaScript/Reference/Operators/Comparison_Operators">less-than와 greater-than 연산자</a>만을 사용하여 문자열을 비교할 수 있습니다<span style="line-height: inherit;"> </span><span style="line-height: inherit;">:</span></p> +<p>C 개발자는 문자열 비교를 위하여 <code>strcmp()</code> 함수를 사용합니다. JavaScript에서는 단지 <a href="/ko/docs/Web/JavaScript/Reference/Operators/Comparison_Operators">less-than와 greater-than 연산자</a>만을 사용하여 문자열을 비교할 수 있습니다:</p> <pre class="brush: js">var a = "a"; var b = "b"; @@ -160,11 +160,11 @@ if (a < b) { // true } </pre> -<p>비슷한 결과를 얻을 수 있는 방법으로 <span style="font-family: courier new,andale mono,monospace;">String</span> 인스턴스에서 상속된 {{jsxref("String.prototype.localeCompare()", "localeCompare()")}} 메서드를 사용할 수 있습니다.</p> +<p>비슷한 결과를 얻을 수 있는 방법으로 String 인스턴스에서 상속된 {{jsxref("String.prototype.localeCompare()", "localeCompare()")}} 메서드를 사용할 수 있습니다.</p> <h3 id="문자열_원형과_String_객체의_차이">문자열 원형과 <code>String</code> 객체의 차이</h3> -<div>JavaScript는 <code>String</code> 오브젝트와 원형의 문자열을 다르게 취급한다는 것에 주의해야 합니다. ({{jsxref("Boolean")}}과 <a href="/ko/docs/Web/JavaScript/Reference/Global_Objects" title="JavaScript/Reference/Global_Objects/">숫자</a>의 true도 마찬가지입니다.)</div> +<div>JavaScript는 <code>String</code> 오브젝트와 원형의 문자열을 다르게 취급한다는 것에 주의해야 합니다. ({{jsxref("Boolean")}}과 <a href="/ko/docs/Web/JavaScript/Reference/Global_Objects">숫자</a>의 true도 마찬가지입니다.)</div> <div> </div> @@ -187,19 +187,19 @@ console.log(eval(s2)); // returns the string "2 + 2" <p>이러한 이유로, 비록 코드 상에서 원형 문자열을 사용하는 대신에 <code>String</code> 오브젝트를 사용하게 되면 코드가 손상될 수 있지만, 일반적인 개발자는 차이를 걱정할 필요는 없습니다.</p> -<p><code>String</code><span style="line-height: inherit;"> 오브젝트는 언제든지 </span>{{jsxref("String.prototype.valueOf()", "valueOf()")}} <span style="line-height: inherit;"> 메서드로 원형에 대응하도록 전환할 수 있습니다.</span></p> +<p><code>String</code> 오브젝트는 언제든지 </span>{{jsxref("String.prototype.valueOf()", "valueOf()")}} 메서드로 원형에 대응하도록 전환할 수 있습니다.</span></p> <pre class="brush: js">console.log(eval(s2.valueOf())); // returns the number 4 </pre> -<h2 id="Properties" name="Properties">속성</h2> +<h2 id="Properties">속성</h2> <dl> <dt>{{jsxref("String.prototype")}}</dt> <dd>String 오브젝트는 프로퍼티의 추가가 가능합니다.</dd> </dl> -<h2 id="Methods" name="Methods">메서드</h2> +<h2 id="Methods">메서드</h2> <dl> <dt>{{jsxref("String.fromCharCode()")}}</dt> @@ -216,15 +216,15 @@ console.log(eval(s2)); // returns the string "2 + 2" <p><strong><code>String</code> generic들은 비표준으로, 가까운 미래에 사라질 것입니다.</strong> 아래에서 제공하고 있는 방식을 사용하지 않으면, 브라우저들간의 호환성은 기대하기 어렵습니다. </p> </div> -<p><code>String</code><span style="line-height: inherit;"> 인스턴스 메서드는 JavScript 1.6으로 Firefox에서(ECMAScript 표준에 속하지는 않지만) 어떤 오브젝트라도 String 메서드에 적용하여 String 오브젝트에서 사용가능합니다:</span></p> +<p><code>String</code> 인스턴스 메서드는 JavScript 1.6으로 Firefox에서(ECMAScript 표준에 속하지는 않지만) 어떤 오브젝트라도 String 메서드에 적용하여 String 오브젝트에서 사용가능합니다:</p> <pre class="brush: js">var num = 15; console.log(String.replace(num, /5/, '2')); </pre> -<p class="brush: js">{{jsxref("Global_Objects/Array", "Generics", "#Array_generic_methods", 1)}}은<span style="line-height: inherit;"> </span>{{jsxref("Global_Objects/Array", "Array")}}<span style="line-height: inherit;"> 메서드에도 사용 가능합니다.</span></p> +<p>{{jsxref("Global_Objects/Array", "Generics", "#Array_generic_methods", 1)}}은 {{jsxref("Global_Objects/Array", "Array")}} 메서드에도 사용 가능합니다.</p> -<h2 id="String_instances" name="String_instances"><code>String</code> 인스턴스</h2> +<h2 id="String_instances"><code>String</code> 인스턴스</h2> <h3 id="속성">속성</h3> @@ -252,7 +252,7 @@ for (var i = 0, n = inputValues.length; i < n; ++i) { } </pre> -<h2 id="Browser_Compatibility" name="Browser_Compatibility">명세</h2> +<h2 id="Browser_Compatibility">명세</h2> <table class="standard-table"> <tbody> @@ -284,7 +284,7 @@ for (var i = 0, n = inputValues.length; i < n; ++i) { </tbody> </table> -<h2 id="Browser_Compatibility" name="Browser_Compatibility">브라우저 호환성</h2> +<h2 id="Browser_Compatibility">브라우저 호환성</h2> diff --git a/files/ko/web/javascript/reference/global_objects/string/repeat/index.html b/files/ko/web/javascript/reference/global_objects/string/repeat/index.html index 1e8398e41e..dfea5e722d 100644 --- a/files/ko/web/javascript/reference/global_objects/string/repeat/index.html +++ b/files/ko/web/javascript/reference/global_objects/string/repeat/index.html @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat <h2 id="폴리필">폴리필</h2> -<p><code>repeat</code>은 ECMAScript 2015 명세에 추가됐습니다. 따라서 어떤 표준 구현체에서는 사용할 수 없을 수도 있습니다. 그러나 아래 코드를 포함하면 지원하지 않는 플랫폼에서도 <font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">repeat</span></font>을 사용할 수 있습니다.</p> +<p><code>repeat</code>은 ECMAScript 2015 명세에 추가됐습니다. 따라서 어떤 표준 구현체에서는 사용할 수 없을 수도 있습니다. 그러나 아래 코드를 포함하면 지원하지 않는 플랫폼에서도 <code>repeat</code>을 사용할 수 있습니다.</p> <pre dir="rtl"><code>if (!String.prototype.repeat) { String.prototype.repeat = function(count) { diff --git a/files/ko/web/javascript/reference/global_objects/string/replace/index.html b/files/ko/web/javascript/reference/global_objects/string/replace/index.html index 3b189bfbf5..e2ad4f5cb0 100644 --- a/files/ko/web/javascript/reference/global_objects/string/replace/index.html +++ b/files/ko/web/javascript/reference/global_objects/string/replace/index.html @@ -1,6 +1,7 @@ --- title: String.prototype.replace() slug: Web/JavaScript/Reference/Global_Objects/String/replace +browser-compat: javascript.builtins.String.replace translation_of: Web/JavaScript/Reference/Global_Objects/String/replace --- <div>{{JSRef}}</div> @@ -95,7 +96,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replace <td><code>p1,<br> p2,<br> ...</code></td> - <td>윗쪽의 $n 표현식과 동일합니다. (<code>$1</code>은 <code>p1</code>, <code>$2</code>는 <code>p2</code>...) 예를 들어, 만약 정규표현식 <code>/(\a+)(\b+)/</code> 이 주어진다면<code><font face="Open Sans, Arial, sans-serif"> </font></code><code>p1</code>은 <code>\a+</code>와 매치되고 <code>p2</code>는 <code>\b+</code>와 매치됩니다.</td> + <td>윗쪽의 $n 표현식과 동일합니다. (<code>$1</code>은 <code>p1</code>, <code>$2</code>는 <code>p2</code>...) 예를 들어, 만약 정규표현식 <code>/(\a+)(\b+)/</code> 이 주어진다면<code>p1</code>은 <code>\a+</code>와 매치되고 <code>p2</code>는 <code>\b+</code>와 매치됩니다.</td> </tr> <tr> <td><code>offset</code></td> @@ -277,18 +278,7 @@ console.log(retArr); <h2 id="브라우저_호환성">브라우저 호환성</h2> -<div> </div> - -<div id="compat-mobile">{{Compat("javascript.builtins.String.replace")}}</div> - -<h2 id="Firefox-specific_notes">Firefox-specific notes</h2> - -<ul> - <li>Starting with Gecko 27 {{geckoRelease(27)}}, this method has been adjusted to conform with the ECMAScript specification. When <code>replace()</code> is called with a global regular expression, the {{jsxref("RegExp.lastIndex")}} property (if specified) will be reset to <code>0</code> ({{bug(501739)}}).</li> - <li>Starting with Gecko 39 {{geckoRelease(39)}}, the non-standard <code>flags</code> argument is deprecated and throws a console warning ({{bug(1142351)}}).</li> - <li>Starting with Gecko 47 {{geckoRelease(47)}}, the non-standard <code>flags</code> argument is no longer supported in non-release builds and will soon be removed entirely ({{bug(1245801)}}).</li> - <li>Starting with Gecko 49 {{geckoRelease(49)}}, the non-standard <code>flags</code> argument is no longer supported ({{bug(1108382)}}).</li> -</ul> +<div>{{Compat}}</div> <h2 id="같이_보기">같이 보기</h2> diff --git a/files/ko/web/javascript/reference/global_objects/string/split/index.html b/files/ko/web/javascript/reference/global_objects/string/split/index.html index 83d8136caa..a5b0df228e 100644 --- a/files/ko/web/javascript/reference/global_objects/string/split/index.html +++ b/files/ko/web/javascript/reference/global_objects/string/split/index.html @@ -22,7 +22,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/split <pre class="syntaxbox"><var>str</var>.split([<var>separator</var>[, <var>limit</var>]])</pre> <div class="warning"> -<p><strong>주의:</strong> 구분자로 빈 문자열(<code>""</code>)을 제공하면, 사용자가 인식하는 문자 하나(<a href="https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries">grapheme cluster</a>) 또는 유니코드 문자(코드포인트) 하나씩으로 나누는 것이 아니라, UTF-16 코드유닛으로 나누게 되며 <a href="http://unicode.org/faq/utf_bom.html#utf16-2">써로게이트 페어</a><sup>surrogate pair</sup>가 망가질 수 있습니다. 스택 오버플로우의 <a href="https://stackoverflow.com/a/34717402">How do you get a string to a character array in JavaScript?</a> 질문도 참고해 보세요.</p> +<p><strong>주의:</strong> 구분자로 빈 문자열(<code>""</code>)을 제공하면, 사용자가 인식하는 문자 하나(<a href="https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries">grapheme cluster</a>) 또는 유니코드 문자(코드포인트) 하나씩으로 나누는 것이 아니라, UTF-16 코드유닛으로 나누게 되며 <a href="http://unicode.org/faq/utf_bom.html#utf16-2">써로게이트 페어</a>가 망가질 수 있습니다. 스택 오버플로우의 <a href="https://stackoverflow.com/a/34717402">How do you get a string to a character array in JavaScript?</a> 질문도 참고해 보세요.</p> </div> <h3 id="매개변수">매개변수</h3> @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/split <p>문자열에서 <code>separator</code>가 등장하면 해당 부분은 삭제되고 남은 문자열이 배열로 반환됩니다. <code>separator</code>가 등장하지 않거나 생략되었을 경우 배열은 원본 문자열을 유일한 원소로 가집니다. <code>separator</code>가 빈 문자열일 경우, <code>str</code>은 문자열의 모든 문자를 원소로 가지는 배열로 변환됩니다. <code>separator</code>가 원본 문자열의 처음이나 끝에 등장할 경우 반환되는 배열도 빈 문자열로 시작하거나 끝납니다. 그러므로 원본 문자열에 <code>separator</code> 하나만이 포함되어 있을 경우 빈 문자열 두 개를 원소로 가지는 배열이 반환됩니다.</p> -<p><code>separator</code>가 포획 괄호<sup>capturing parentheses</sup>를 포함하는 정규표현식일 경우, <code>separator</code>가 일치할 때마다 포획 괄호의 (정의되지 않은 경우도 포함한) 결과가 배열의 해당 위치에 포함됩니다.</p> +<p><code>separator</code>가 포획 괄호를 포함하는 정규표현식일 경우, <code>separator</code>가 일치할 때마다 포획 괄호의 (정의되지 않은 경우도 포함한) 결과가 배열의 해당 위치에 포함됩니다.</p> <p>{{Note("<code>separator</code>가 배열일 경우 분할에 사용하기 전에 우선 문자열로 변환됩니다.")}}</p> diff --git a/files/ko/web/javascript/reference/global_objects/string/substring/index.html b/files/ko/web/javascript/reference/global_objects/string/substring/index.html index b4dbd8c170..269871d785 100644 --- a/files/ko/web/javascript/reference/global_objects/string/substring/index.html +++ b/files/ko/web/javascript/reference/global_objects/string/substring/index.html @@ -5,7 +5,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substring --- <div>{{JSRef}}</div> -<p><strong><code>substring()</code></strong><font><font>메소드는 string 객체의 시작 인덱스로 부터 종료 인덱스 전 까지 문자열의 부분 문자열을 반환합니다. </font></font></p> +<p><strong><code>substring()</code></strong> 메소드는 string 객체의 시작 인덱스로 부터 종료 인덱스 전 까지 문자열의 부분 문자열을 반환합니다.</p> <div>{{EmbedInteractiveExample("pages/js/string-substring.html")}}</div> diff --git a/files/ko/web/javascript/reference/global_objects/string/tostring/index.html b/files/ko/web/javascript/reference/global_objects/string/tostring/index.html deleted file mode 100644 index 197b679edd..0000000000 --- a/files/ko/web/javascript/reference/global_objects/string/tostring/index.html +++ /dev/null @@ -1,58 +0,0 @@ ---- -title: String.prototype.toString() -slug: Web/JavaScript/Reference/Global_Objects/String/toString -translation_of: Web/JavaScript/Reference/Global_Objects/String/toString ---- -<div><font><font>{{JSRef}}</font></font></div> - -<p><font><font>이 </font></font><strong><code>toString()</code></strong><font><font>메소드는 지정된 객체를 나타내는 문자열을 반환합니다.</font></font></p> - -<div><font><font>{{EmbedInteractiveExample ( "pages / js / string-tostring.html")}}</font></font></div> - -<h2 id="통사론"><font><font>통사론</font></font></h2> - -<pre class="syntaxbox"><code><var>str</var>.toString()</code></pre> - -<h3 id="반환_값"><font><font>반환 값</font></font></h3> - -<p><font><font>호출 객체를 나타내는 문자열</font></font></p> - -<h2 id="기술"><font><font>기술</font></font></h2> - -<p><font><font>{{jsxref ( "String")}} 오브젝트 </font></font><code>toString()</code><font><font>는 {{jsxref ( "Object")}} 오브젝트 </font><font>의 </font><font>메소드를 </font><font>대체 </font><font>합니다. </font><font>{{jsxref ( "Object.prototype.toString ()")}}을 상속하지 않습니다. </font><font>{{jsxref ( "String")}} 오브젝트의 경우 </font></font><code>toString()</code><font><font>메소드는 </font><font>오브젝트 </font><font>의 문자열 표시를 리턴하며 {{jsxref ( "String.prototype.valueOf ()")}} 메소드와 동일합니다.</font></font></p> - -<h2 id="예"><font><font>예</font></font></h2> - -<h3 id="사용_toString"><font><font>사용 </font></font><code>toString()</code></h3> - -<p><font><font>다음 예제는 {{jsxref ( "String")}} 오브젝트의 문자열 값을 표시합니다.</font></font></p> - -<pre class="brush: js"><font><font>var x = new String ( 'Hello world');</font></font> -<font><font> -console.log (x.toString ()); </font><font>// 'Hello world'를 기록합니다.</font></font> -</pre> - -<h2 id="명세서"><font><font>명세서</font></font></h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col"><font><font>사양</font></font></th> - </tr> - <tr> - <td><font><font>{{SpecName ( 'ESDraft', '# sec-string.prototype.tostring', 'String.prototype.toString')}}}</font></font></td> - </tr> - </tbody> -</table> - -<h2 id="브라우저_호환성"><font><font>브라우저 호환성</font></font></h2> - - -<p><font><font>{{Compat ( "javascript.builtins.String.toString")}}</font></font></p> - -<h2 id="또한보십시오"><font><font>또한보십시오</font></font></h2> - -<ul> - <li><font><font>{{jsxref ( "Object.prototype.toSource ()")}}</font></font></li> - <li><font><font>{{jsxref ( "String.prototype.valueOf ()")}}</font></font></li> -</ul> diff --git a/files/ko/web/javascript/reference/global_objects/string/tostring/index.md b/files/ko/web/javascript/reference/global_objects/string/tostring/index.md new file mode 100644 index 0000000000..27d2453fd8 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/string/tostring/index.md @@ -0,0 +1,56 @@ +--- +title: String.prototype.toString() +slug: Web/JavaScript/Reference/Global_Objects/String/toString +tags: + - JavaScript + - Method + - Prototype + - Reference + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/toString +browser-compat: javascript.builtins.String.toString +--- + +{{JSRef}} + +**`toString()`** 메서드는 객체의 문자열 표현을 반환합니다. + +{{EmbedInteractiveExample("pages/js/string-tostring.html")}} + +## 구문 + +```js +toString() +``` + +### 반환 값 + +메서드를 호출하는 객체의 문자열 표현. + +## 설명 + +{{jsxref("String")}} 객체는 {{jsxref("Object")}} 객체의 `toString()` 메서드를 상속하지 않고 재정의합니다. {{jsxref("String")}} 의 `toString()` 메서드는 객체의 문자열 표현을 반환하며 {{jsxref("String.prototype.valueOf()")}} 메서드와 동일합니다. + +## 예제 + +### `toString()` 사용하기 + +{{jsxref("String")}} 객체의 문자열 값을 표시하는 예제입니다. + +```js +var x = new String('Hello world') + +console.log(x.toString()) // logs 'Hello world' +``` + +## 명세 + +{{Specifications}} + +## 브라우저 호환성 + +{{Compat}} + +## 같이 보기 + +- {{jsxref("String.prototype.valueOf()")}} diff --git a/files/ko/web/javascript/reference/global_objects/string/trimstart/index.html b/files/ko/web/javascript/reference/global_objects/string/trimstart/index.html deleted file mode 100644 index df264d0078..0000000000 --- a/files/ko/web/javascript/reference/global_objects/string/trimstart/index.html +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: String.prototype.trimStart() -slug: Web/JavaScript/Reference/Global_Objects/String/trimStart -tags: -- JavaScript -- Method -- Prototype -- Reference -- String -- Polyfill -browser-compat: javascript.builtins.String.trimStart -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> - - -<h2 id="syntax">구문</h2> - -<pre class="brush: js"> -trimStart() - -trimLeft() -</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.padStart")}}표준 메서드 이름과 같은 함수의 일관성을 위해서<code>trimStart</code>가 되었습니다. 그러나, - 웹 호환성을 위해서 <code>trimLeft</code> 이라는 별칭을 가집니다. 일부 엔진에서 이것은 다음 예시를 의미합니다.</p> - -<pre class="brush: js">String.prototype.trimLeft.name === "trimStart";</pre> - -<h2 id="examples">예제</h2> - -<h3 id="using_trimStart">trimStart() 사용</h3> - -<p>다음 예제는<code>'foo '</code>문자열을 표시합니다.</p> - -<pre class="brush: js highlight: [5]">var str = ' foo '; - -console.log(str.length); // 8 - -str = str.trimStart(); -console.log(str.length); // 5 -console.log(str); // 'foo ' -</pre> - -<h2 id="polyfill">폴리필</h2> - -<pre class="brush: js highlight: [5]">//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=>{ - const String=w.String, Proto=String.prototype; - - ((o,p)=>{ - 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">명세서</h2> - -{{Specifications}} - -<h2 id="browser_compatibility">브라우저 호환성</h2> - -<p>{{Compat}}</p> - -<h2 id="See_also">같이 보기</h2> - -<ul> - <li><code>String.prototype.trimStart</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.trimEnd()")}}</li> -</ul> diff --git a/files/ko/web/javascript/reference/global_objects/string/trimstart/index.md b/files/ko/web/javascript/reference/global_objects/string/trimstart/index.md new file mode 100644 index 0000000000..46291bea6b --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/string/trimstart/index.md @@ -0,0 +1,106 @@ +--- +title: String.prototype.trimStart() +slug: Web/JavaScript/Reference/Global_Objects/String/trimStart +tags: +- JavaScript +- Method +- Prototype +- Reference +- String +- Polyfill +browser-compat: javascript.builtins.String.trimStart +translation_of: Web/JavaScript/Reference/Global_Objects/String/trimStart +--- +{{JSRef}} + +**`trimStart()`** 메서드는 문자열 시작부분의 공백을 제거합니다. 또한 `trimLeft()`라는 별칭으로 호출이 가능합니다. +{{EmbedInteractiveExample("pages/js/string-trimstart.html")}} + +## 구문 + +```js +trimStart() + +trimLeft() +``` + +### 반환값 + +`str` 시작부분(왼쪽)에서 공백이 제거된 새 문자열을 반환합니다. +`str` 에 공백이 없을시에도 에러가 발생하지 않고 여전히 새 문자열(본질적으로 `str` 의 복사본)이 반환됩니다. + +### 별칭 + +{{jsxref("String.prototype.padStart")}} 표준 메서드 이름과 같은 함수의 일관성을 위해서 `trimStart` 가 되었습니다. +그러나, 웹 호환성을 위해서 `trimLeft` 이라는 별칭을 가집니다. 일부 엔진에서 이것은 다음 예시를 의미합니다. + +```js +String.prototype.trimLeft.name === "trimStart"; +``` + +## 예제 + +### trimStart() 사용 + +다음 예제는 `'foo '` 문자열을 표시합니다. + +```js +var str = ' foo '; + +console.log(str.length); // 8 + +str = str.trimStart(); +console.log(str.length); // 5 +console.log(str); // 'foo ' +``` + +## 폴리필 + +```js +//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=>{ + const String=w.String, Proto=String.prototype; + + ((o,p)=>{ + if(p in o?o[p]?false:true:true){ + const r=/^\s+/; + o[p]=o.trimLeft||function(){ + return this.replace(r,'') + } + } + })(Proto,'trimStart'); + +})(window); +*/ +``` + +## 명세서 + +{{Specifications}} + +## 브라우저 호환성 + +{{Compat}} + +## 같이 보기 + +- `String.prototype.trimStart` 의 폴리필은 [`core-js`](https://github.com/zloirock/core-js#ecmascript-string-and-regexp)를 참고하세요. +- {{jsxref("String.prototype.trim()")}} +- {{jsxref("String.prototype.trimEnd()")}} |