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

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

parseFloat()

Baseline
Widely available

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

parseFloat() ( )

In this article

function circumference(r) {
  return parseFloat(r) * 2.0 * Math.PI;
}

console.log(circumference(4.567));
// Expected output: 28.695307297889173

console.log(circumference("4.567abcdefgh"));
// Expected output: 28.695307297889173

console.log(circumference("abcdefgh"));
// Expected output: NaN

parseFloat()

, .

, . , NaN.

parseFloat - , .

parseFloat , . , (+ -), (0-9), , , , , . .

, parseFloat NaN.

, NaN - . , parseFloat NaN , isNaN. NaN , NaN.

parseFloat Infinity (""). isFinite, , (not Infinity, -Infinity, NaN).

parseFloat

3.14

parseFloat(3.14);
parseFloat('3.14');
parseFloat('314e-2');
parseFloat('0.0314E+2');
parseFloat('3.14-   ');

var foo = Object.create(null);
foo.toString = function () { return "3.14"; };
parseFloat(foo);

var foo = Object.create(null);
foo.valueOf = function () { return "3.14"; };
parseFloat(foo);

parseFloat NaN

NaN

js
parseFloat("FF2");

Specification
ECMAScript 2027 LanguageSpecification
# sec-parsefloat-string


Web Proxy Viewer  |  New URL  |  Original Page