[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat [Back]  [Original]

Number.parseFloat() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Number.parseFloat()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 9.

Number.parseFloat() . NaN .

In this article

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

js
Number.parseFloat(string);

string

. ToString . .

.

NaN .

Number.parseFloat vs parseFloat

Number.parseFloat() parseFloat() .

js
Number.parseFloat === parseFloat; // true

Number.parseFloat() ECMAScript 2015 . parseFloat() .

Specification
ECMAScript 2027 LanguageSpecification
# sec-number.parsefloat


Web Proxy Viewer  |  New URL  |  Original Page