Number.parseInt() 메서드는 문자열을 분석하고 특정 진수를 사용한 정수로 변환해 반환합니다.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
구문
Number.parseInt(string,[ radix])
매개변수
string- 분석할 값. 만약
string이 문자열이 아니면 문자열로 변환(ToString추상 연산을 사용)합니다. 문자열의 선행 공백은 무시합니다.
radixstring이 표현하는 정수를 나타내는 2와 36 사이의 진수(수의 진법 체계에 기준이 되는 값).
반환 값
주어진 문자열로부터 분석한 정수. 첫 글자를 숫자로 변환할 수 없다면 NaN을 반환합니다.
설명
Number.parseInt() 메서드는 전역 parseInt() 함수와 같은 기능을 가지고 있습니다.
Number.parseInt === parseInt; // true
Number.parseInt()는 ECMAScript 2015에서 전역 범위의 모듈화를 위해 추가됐습니다. 상세한 정보와 예제는 parseInt()를 참고하세요.
폴리필
if (Number.parseInt === undefined) {
Number.parseInt = window.parseInt;
}
명세
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Number.parseInt' in that specification. |
Standard | Initial definition. |
| ECMAScript Latest Draft (ECMA-262) The definition of 'Number.parseInt' in that specification. |
Draft |
브라우저 호환성
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parseInt | Chrome Full support 34 | Edge Full support 12 | Firefox Full support 25 | IE No support No | Opera Full support 21 | Safari Full support 9 | WebView Android Full support ≤37 | Chrome Android Full support 34 | Firefox Android Full support 25 | Opera Android Full support 21 | Safari iOS Full support 9 | Samsung Internet Android Full support 2.0 | nodejs Full support 0.12 |
Legend
- Full support
- Full support
- No support
- No support
같이 보기
- 메서드가 속한
Number객체. - 전역
parseInt()메서드.