Adscend

Click Here



Click Here

Tuesday

Data Type Convert String to Float

ii)String to Float

Syntax: parseFloat(string)

To convert a value from string to float, we have to use the function or method parseFloat(). 
The parseFloat() function parses a string and returns a floating point number.


Example

<html>
<body>

<script type="text/javascript">

document.write(parseFloat ("35.49") + "<br />");
document.write(parseFloat ("35.00000000")+ "<br />");
document.write(parseFloat ("35") + "<br />");
document.write(parseFloat ("0x35")+ "<br />");
document.write(parseFloat ("035")+ "<br />");
document.write(parseFloat ("Hello")+ "<br />");

</script>


</body>
</html>

Output


Click the buttons below and see what outputs give.










No comments:

Post a Comment