diff options
| author | alattalatta <urty5656@gmail.com> | 2021-11-21 21:51:19 +0900 |
|---|---|---|
| committer | hochan Lee <hochan049@gmail.com> | 2021-12-14 01:02:01 +0900 |
| commit | 340005cf0505a16d18fb63bedb42cc0db0e87a38 (patch) | |
| tree | 9b1d8b4f9bf2fd222d87cedcc447ee8ebb3739f4 /files/ko/web/javascript/reference/global_objects/number/parseint | |
| parent | 751187f65c9eec62df17f46166f1b9faaec4c61e (diff) | |
| download | translated-content-340005cf0505a16d18fb63bedb42cc0db0e87a38.tar.gz translated-content-340005cf0505a16d18fb63bedb42cc0db0e87a38.tar.bz2 translated-content-340005cf0505a16d18fb63bedb42cc0db0e87a38.zip | |
Update parseFloat/parseInt
Diffstat (limited to 'files/ko/web/javascript/reference/global_objects/number/parseint')
| -rw-r--r-- | files/ko/web/javascript/reference/global_objects/number/parseint/index.md | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/files/ko/web/javascript/reference/global_objects/number/parseint/index.md b/files/ko/web/javascript/reference/global_objects/number/parseint/index.md index 0b0a052016..54d0f3f06f 100644 --- a/files/ko/web/javascript/reference/global_objects/number/parseint/index.md +++ b/files/ko/web/javascript/reference/global_objects/number/parseint/index.md @@ -6,73 +6,63 @@ tags: - JavaScript - Method - Number - - Reference + - Polyfill +browser-compat: javascript.builtins.Number.parseInt translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseInt --- -<div>{{JSRef}}</div> +{{JSRef}} -<p><strong><code>Number.parseInt()</code></strong> 메서드는 문자열을 분석하고 특정 진수를 사용한 정수로 변환해 반환합니다.</p> +**`Number.parseInt()`** 메서드는 문자열 인자를 파싱하여 특정 진수(수의 진법 체계에서 기준이 되는 값)의 정수를 반환합니다. -<div>{{EmbedInteractiveExample("pages/js/number-parseint.html")}}</div> +{{EmbedInteractiveExample("pages/js/number-parseint.html", "taller")}} +## 구문 +```js +Number.parseInt(string) +Number.parseInt(string, radix) +``` -<h2 id="구문">구문</h2> +### 매개변수 -<pre class="syntaxbox">Number.parseInt(<var>string,</var>[ <var>radix</var>]) -</pre> +- `string` + - : 파싱할 값입니다. 문자열이 아닐 경우 [`ToString`](https://tc39.es/ecma262/#sec-tostring) 추상 연산을 사용해 문자열로 변환합니다. 문자열의 선행 공백은 무시합니다. +- `radix` {{optional_inline}} + - : `string`의 진수를 나타내는 `2`부터 `36`까지의 정수입니다. -<h3 id="매개변수">매개변수</h3> + `radix`를 생략하거나 `0`을 지정한 경우, `string`이 `0x` 또는 `0X`로 시작하는 경우 `16`을 지정한 것으로 취급하고, 그 외의 경우 `10`으로 취급합니다. -<div>{{page("ko/docs/Web/JavaScript/Reference/Global_Objects/parseInt", "매개변수")}}</div> +### 반환 값 -<h3 id="반환_값">반환 값</h3> +주어진 `string`에서 파싱한 정수입니다. -<p>{{page("ko/docs/Web/JavaScript/Reference/Global_Objects/parseInt", "반환 값")}}</p> +다음과 같은 경우에는 {{jsxref("NaN")}}을 반환합니다. -<h2 id="설명">설명</h2> +- `radix`가 2보다 작거나 36보다 큰 경우. +- 공백이 아닌 첫 문자를 숫자로 변환할 수 없는 경우. -<p><code>Number.parseInt()</code> 메서드는 전역 {{jsxref("parseInt", "parseInt()")}} 함수와 같은 기능을 가지고 있습니다.</p> +## 설명 -<pre class="brush: js">Number.parseInt === parseInt; // true</pre> +### Number.parseInt vs parseInt -<p><code>Number.parseInt()</code>는 ECMAScript 2015에서 전역 범위의 모듈화를 위해 추가됐습니다. 상세한 정보와 예제는 {{jsxref("parseInt", "parseInt()")}}를 참고하세요.</p> +`Number.parseInt()`는 전역 {{jsxref("parseInt", "parseInt()")}} 함수와 같은 기능을 가지고 있습니다. -<h2 id="폴리필">폴리필</h2> +```js +Number.parseInt === parseInt; // true +``` -<pre class="brush: js">if (Number.parseInt === undefined) { - Number.parseInt = window.parseInt; -}</pre> +`Number.parseInt()`는 ECMAScript 2015에서 전역 객체의 모듈화를 위해 추가됐습니다. 상세한 정보와 예제는 {{jsxref("parseInt", "parseInt()")}}를 참고하세요. -<h2 id="명세">명세</h2> +## 명세 -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-number.parseint', 'Number.parseInt')}}</td> - <td>{{Spec2('ES6')}}</td> - <td>Initial definition.</td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-number.parseint', 'Number.parseInt')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </td> - </tr> - </tbody> -</table> +{{Specifications}} -<h2 id="브라우저_호환성">브라우저 호환성</h2> +## 브라우저 호환성 -<div>{{Compat("javascript.builtins.Number.parseInt")}}</div> +{{Compat}} -<h2 id="같이_보기">같이 보기</h2> +## 같이 보기 -<ul> - <li>메서드가 속한 {{jsxref("Number")}} 객체.</li> - <li>전역 {{jsxref("parseInt", "parseInt()")}} 메서드.</li> -</ul> +- `core-js`의 [`Number.parseInt` 폴리필](https://github.com/zloirock/core-js#ecmascript-number) +- 이 메서드가 속한 {{jsxref("Number")}} 객체 +- 전역 {{jsxref("parseInt", "parseInt()")}} 메서드 |
