Udostępnij za pośrednictwem


parseFloat Method

Returns a floating-point number converted from a string.

function parseFloat(numString : String) : Number

Arguments

  • numString
    Required. A string that represents a floating-point number.

Remarks

The parseFloat method returns a numerical value equal to the number contained in numString. If no prefix of numString can be successfully parsed into a floating-point number, NaN (not a number) is returned.

You can test for NaN using the isNaN method.

Example

In following example, the parseFloat method is used to convert two strings to numbers.

parseFloat("abc")      // Returns NaN.
parseFloat("1.2abc")   // Returns 1.2.

Requirements

Version 1

Applies To:

Global Object

See Also

Reference

isNaN Method

parseInt Method

String Object