toFixed Number JavaScript JS

The JavaScript number toFixed() method is used to get the string that represents a number with exact digits after a decimal point.

Syntax:

Number.toFixed(n)

Parameters
n: It represents the number of digits after the decimal point.

Returns
String representation of the specified number with exact digits after a decimal point.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var n= 12.334;
document.writeln(n.toFixed(2));
</script>
</body>
</html>