Number

Number.parseFloat

Parses an argument and returns a floating-point number

Syntax

JavaScript
Number.parseFloat(string)

Parameters

ParameterTypeDescription
stringstringThe value to parse

Return Value

A floating-point number, or NaN if parsing fails

Examples

Basic Usage
console.log(Number.parseFloat('3.14')); // 3.14
console.log(Number.parseFloat('314e-2')); // 3.14
Practical Example
console.log(Number.parseFloat('3.14some text')); // 3.14
console.log(Number.parseFloat('text')); // NaN
Advanced Usage
const prices = ['$9.99', '$14.50', '$3.01'];
const nums = prices.map(p => Number.parseFloat(p.slice(1)));
console.log(nums); // [9.99, 14.5, 3.01]

Understanding Number.parseFloat

The Number.parseFloat method in JavaScript parses an argument and returns a floating-point number. It belongs to the Number object and is one of the most widely used methods for working with number values in modern JavaScript and TypeScript applications.

The method signature is Number.parseFloat(string). It accepts 1 parameter: string. When called, it returns a floating-point number, or nan if parsing fails. Understanding when and how to use parseFloat() helps you write more expressive, readable code.

Common use cases for Number.parseFloat include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like number-parseint, number-isnan, number-isfinite, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Number.parseFloat is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Number Methods

Other methods in the Number object

Related Tools

More Number Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.