JavaScriptNumbertoFixed

Formats a number using fixed-point notation.

Syntax

(number).toFixed(digits)

Example

Enter values below to update the example in real time.

const
console
toFixed
const pi = 3.14159265;
console.log(pi.toFixed(2));   // "3.14"
console.log(pi.toFixed(4));   // "3.1416"