Skip to content
🧠 Master React Package Creation — Claim Your Spot

toFixed() Method – How to Fix the Number of Decimal Digits

toFixed() specifies the number of digits browsers should show after a number’s decimal point.

toFixed() accepts only one optional argument. Here is the syntax:

number.toFixed(totalFractionDigits);

The totalFractionDigits argument specifies the number of digits browsers should show after the number’s decimal point. If omitted, browsers will use 0—which means it will add no digits after the decimal point.

Below are examples of the toFixed() method.

const number = 703.59;
number.toFixed(); // Equivalent to number.toFixed(0)
// The invocation above will return: 704

Try Editing It

const number = 703.59;
number.toFixed(1);
// The invocation above will return: 703.6

Try Editing It

const number = 703.59;
number.toFixed(3);
// The invocation above will return: 703.590

Try Editing It

const number = 703.59;
number.toFixed(7);
// The invocation above will return: 703.5900000

Try Editing It