ScanSkill

parseFloat()

The parseFloat() function parses the passed value (converting it to a string first if needed) and returns a floating-point number.

Syntax

parseFloat(4.226)

Example

let number = "1203.234234";

console.log(5 + parseFloat(number)); // Prints: 1208.234234

The parseFloat() function parses the given parameter into a floating-point number. It also converts strings to numbers if possible, while ignoring whitespace.