Javascript - parseFloat() function


parseFloat() function looks at each character starting in position 0.

It continues to parse the string until it reaches either the end of the string or a character that is invalid in a floating-point number.

This means that a decimal point is valid the first time it appears, but a second decimal point is invalid and the rest of the string is ignored.

"12.34.5" being converted to 12.34.

In parseFloat() initial zeros are always ignored.

parseFloat() parses only decimal values, there is no radix mode.

If the string represents a whole number, parseFloat() returns an integer.

var num1 = parseFloat("1234asdf");    //1234 - integer 
var num2 = parseFloat("0xA");         //0 
var num3 = parseFloat("12.5");        //12.5 
var num4 = parseFloat("22.34.5");     //22.34 
var num5 = parseFloat("0808.5");      //808.5 
var num6 = parseFloat("3.125e7");     //31250000