Standard built-ins

parseFloat()

Try the free JavaScript compiler

Reads a decimal floating-point prefix, including exponent notation or Infinity, and ignores trailing invalid text. Returns NaN if no valid prefix exists.

Formal Syntax & Structure

javascript syntaxjavascript
parseFloat(value)

Parameters & Attributes

NameTypeDescription
valueanyConverted to text before parsing.

Return Value

number

Parsed Number, possibly NaN.

Working Example

Example Snippetjavascript
console.log(parseFloat("12px"));
JavaScript Reference