Use parseFloat() with to toFixed() method to convert int to float in JavaScript. Where toFixed() method formats a number using fixed-point notation. Read MDN Web Docs for full reference.
Example int to float in JavaScript
Simple example code parseFloat takes in a string value and converts it to float.
<!DOCTYPE html>
<html>
<head>
<script>
var n = 10;
var res = parseFloat(n).toFixed(2);
console.log(res);
var x = 8;
var out = parseFloat(x).toFixed(3);
console.log(out);
</script>
</head>
<body>
</body>
</html>
Output:
![JavaScript int to float](https://i0.wp.com/tutorial.eyehunts.com/wp-content/uploads/2022/01/JavaScript-int-to-float.jpg?resize=192%2C97&ssl=1)
Do comment if you have any doubts or suggestions on this JS int to float topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version