JavaScript parseFloat() function
INTERACTIVE CORNER
JavaScript employs several built in functions to deal with the conversion of strings to numbers. This tutorial will demonstrate a simple example of the JavaScript parseFloat function.
How JavaScript can process strings from various sources
Imagine you had to write a script which needs to handle real numbers.
If those numbers were a user input, or come from more advanced sources such as a database or as values from another website, JavaScript will treat the information as a string.
How parseFloat() works
The JavaScript parseFloat() function parses a string and returns a floating point number (i.e. any real number that has a decimal place or fractional part). This allows the value to be used in calculations and avoids concantenation when numbers are interpreted as strings.