Number parseFloat() method

Find all information about the JavaScript parseFloat() method of the Number object

Parse the parameter as a floating point number and return it. The parameter is a string:

Number.parseFloat('10') //10
Number.parseFloat('10.00') //10
Number.parseFloat('237,21') //237
Number.parseFloat('237.21') //237.21
Number.parseFloat('12 34 56') //12
Number.parseFloat(' 36 ') //36
Number.parseFloat('36 is my age') //36

Number.parseFloat('-10') //-10
Number.parseFloat('-10.2') //-10.2

as you can seeNumber.parseFloat()Very flexible. It can also convert strings with words toFirstNumber, but the string must start with a number:

Number.parseFloat('I am Flavio and I am 36') //NaN

It only handles base 10 numbers.

Download mine for freeJavaScript beginner's manual

More js tutorials: