Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
parseFloat() 함수는 주어진 값을 필요한 경우 문자열로 변환한 후 부동소수점 실수로 파싱해 반환합니다.
파싱할 값입니다. 문자열이 아닐 경우 ToString 추상 연산을 사용해 문자열로 변환합니다. 문자열의 선행 공백은 무시합니다.
주어진 문자열에서 파싱한 부동소수점 실수입니다.
공백이 아닌 첫 글자를 숫자로 변환할 수 없는 경우 NaN을 반환합니다.
parseFloat은 전역 객체의 함수 속성입니다.
더 엄격한 파싱이 필요하면, 유효하지 않은 문자가 어디에나 존재할 시 NaN을 반환하는 Number(value)를 고려하세요.
parseFloat은 toString이나 valueOf 메서드를 구현한 객체도 파싱할 수 있습니다. 이 때의 결과는 객체의 toString(), valueOf()의 반환 값을 parseFloat에 전달한 것과 동일합니다.
아래 예제는 모두 3.14를 반환합니다.
다음 예제는 NaN을 반환합니다.
다음 예제는 부동소수점 실수로 표현하기엔 너무 큰 수를 받거나 n을 무시해서 정확도를 잃어버린 900719925474099300을 반환합니다.
| ECMAScript® 2027 Language Specification # sec-parsefloat-string |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 2월 11일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.