Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

toFixed Method (Number) (JavaScript)

Represents a number in fixed-point notation.



Required A Number object.


Optional. The number of digits after the decimal point. Must be in the range 0 – 20, inclusive.

Returns a string representation of a number in fixed-point notation, containing fractionDigits digits after the decimal point.

If fractionDigits is not supplied or undefined, the default value is zero.

The following code shows how to use toFixed.

var num = new Number(123);
var fix = num.toFixed();

num = new Number(123.456);
fix = num.toFixed(5);

// Output:
// 123

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Applies To: Number Object (JavaScript)

© 2015 Microsoft