parseFloat

parseFloat – Parses a string as a float

Description

parseFloat(string string)

Parameters

Name Description Type Default Optional
string string No

Return values

Returns a float representation of the string.

Examples

Example #1 – parseFloat example
console.log(parseFloat('123 String')); // 123 console.log(parseFloat('String 123')); // NaN console.log(parseFloat('12')); // 12 console.log(parseFloat(12)); // 12 console.log(parseFloat('12.42')); // 12.42 console.log(parseFloat(Infinity)); // Infinity console.log(parseFloat('Infinity')); // Infinity

See also

External references