parseInt() 함수는 두 개의 매개변수를 받습니다. 하나는 숫자를 나타내는 문자열이고 다른 하나는 기수를 나타내는 숫자이며 주어진 기수의 정수를 반환합니다.
구문
구문은 다음과 같습니다.
num.parseInt('4524', 8); 예시
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var result = parseInt('4524', 8);
document.write("Result: " + result);
</script>
</body>
</html> 출력
Result: 2388
예시
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var result1 = parseInt('4524', 8);
document.write("Result: " + result1);
document.write("<br>");
var result2 = parseInt('4524', 10);
document.write("Result: " + result2);
document.write("<br>");
var result3 = parseInt('4524', 16);
document.write("Result: " + result3);
</script>
</body>
</html> 출력
Result: 2388 Result: 4524 Result: 17700