parseFloat() (Function/global)

Parse a string to extract a floating-point value.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server version - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:-parseFloat(aNumericString)
Argument list:aNumericStringA meaningful numeric value.

The parseFloat() function returns a numeric value is returned, unless the string cannot be resolved to a meaningful value in which case NaN is returned instead.

It produces a number value dictated by interpreting the contents of the string as if it were a decimal literal value. During conversion parseFloat() ignores leading whitespace characters so you don't have to remove them from the string before conversion takes place.

Note that parseFloat() will only process the leading portion of the string. As soon as it encounters an invalid floating-point numeric character it will assume the scanning is complete. It will then silently ignore any remaining characters in the input argument.

See also:Cast operator, Global object, parseInt(), String concatenate (+)

Property attributes:

DontEnum

Cross-references:

ECMA 262 edition 2 - section - 15.1.2.3

ECMA 262 edition 3 - section - 15.1.2.3