JavaScript - toFixed() Number Object

Last Updated Jul 29, 2015, 07:00:14 PM





The JavaScript toFixed() method formats a number using fixed-point notation

Syntax

Parameters

Where digits represents the number of digits appears after the decimal point.


Example

The above example explains how to use method toFixed() i.e., num.toFixed(4). Will display variations in result when changing the value


Try It Now



Other JavaScript Number Object Methods you might want to learn

toString()

valueOf()

toExponential()

toLocaleString()




Sources and Credits

The source of the content has been referred and updated with Mozilla Developer Network and W3C Organization

Last Updated Jul 29, 2015, 07:00:14 PM





Browser compatibility

Feature
toFixed() Yes Yes Yes Yes Yes Yes Yes