CodesJava

Easy learning with example program codes

JavaScript Number parseFloat() method

The JavaScript number parseFloat() method is used to convert a string into a floating point number. It will throw NaN exception if specified can not be converted into float number.

Syntax:

Number.parseFloat(string) 

Parameters
string: It represents the string which have to be converted into floating point number.

Returns
Floating point number.

Example

<!DOCTYPE html>
<html>
<body>
<script>  
var n= 12.334;    
document.writeln(Number.parseFloat("50.5FIVE"));  
</script>  
</body>
</html>

Output

50.5
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status