Number.parseFloat()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since â¨2015ë 9ìâ©.
Number.parseFloat() ë©ìëë 주ì´ì§ ê°ì íìí ê²½ì° ë¬¸ìì´ë¡ ë³íí í ë¶ëììì ì¤ìë¡ íì±í´ ë°íí©ëë¤. ì«ì를 íì±í ì ìë ê²½ì° NaNì ë°íí©ëë¤.
ìëí´ ë³´ê¸°
function circumference(r) {
if (Number.isNaN(Number.parseFloat(r))) {
return 0;
}
return parseFloat(r) * 2.0 * Math.PI;
}
console.log(circumference("4.567abcdefgh"));
// Expected output: 28.695307297889173
console.log(circumference("abcdefgh"));
// Expected output: 0
구문
Number.parseFloat(string);
매ê°ë³ì
ë°í ê°
주ì´ì§ 문ìì´ìì íì±í ë¶ëììì ì¤ìì ëë¤.
ê³µë°±ì´ ìë 첫 ê¸ì를 ì«ìë¡ ë³íí ì ìë ê²½ì° NaNì ë°íí©ëë¤.
ì¤ëª
>Number.parseFloat vs parseFloat
Number.parseFloat()ì ì ì parseFloat() í¨ìì ê°ì 기ë¥ì ê°ì§ê³ ììµëë¤.
Number.parseFloat === parseFloat; // true
Number.parseFloat()ì ECMAScript 2015ìì ì ì ê°ì²´ì 모ëí를 ìí´ ì¶ê°ëìµëë¤. ìì¸í ì ë³´ì ìì ë parseFloat()를 ì°¸ê³ íì¸ì.
ëª ì¸
| Specification |
|---|
| ECMAScript® 2026 Language Specification > # sec-number.parsefloat > |
ë¸ë¼ì°ì í¸íì±
ê°ì´ 보기
core-jsìNumber.parseFloatí´ë¦¬í- ì´ ë©ìëê° ìí
Numberê°ì²´ - ì ì
parseFloat()ë©ìë