Number.parseInt()
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
로부터 분석한 정수.
또는 아래의 경우에는 NaN
을 반환합니다
radix
가 2보다 작거나 36보다 큰 경우- 첫번째 non-whitespace 문자가 숫자로 변환되지 않는 경우
설명
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 (ECMA-262) The definition of 'Number.parseInt' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser
같이 보기
- 메서드가 속한
Number
객체. - 전역
parseInt()
메서드.