Number.toFixed()
AD · 728×90
Google AdSense / Яндекс.Директ
Number
Number.toFixed()
Formats a number to a fixed number of decimal places, returns a string
→ stringPHP: number_format()ES1+
numbernumber
Number to format
digitsnumberoptional
Number of decimal places
(number).toFixed(digits)
RESULT
— click Run or press Ctrl+Enter —
Parameter Reference
ParameterTypeStatusDescription
numbernumberrequiredNumber to format
digitsnumberoptionalNumber of decimal places
About

toFixed() formats a number to a specified number of digits after the decimal point and returns a string. Used for prices, financial data, measurement display. Due to IEEE 754 float representation, (1.005).toFixed(2) may return "1.00" instead of "1.01" — this is a float limitation, not a function bug.

Browser Support

Available since ES3 (1999). Part of Number.prototype. Similar: toPrecision() for total significant digits, toExponential() for scientific notation.

Tips & Gotchas