ES6 - Number.parseFloat



A floating-point number parsed from the given value. If the value cannot be converted to a number, NaN is returned.

Syntax

The syntax given below is for the function Number.parseFloat, where string is the value parse.

Number.parseFloat(string)

Example

<script>
   console.log(Number.parseFloat('10.3meters'));
   console.log(Number.parseFloat('abc10.3xyz'));
</script>

The output of the above code will be as shown below −

10.3
NaN
Advertisements