JavaScript Number toPrecision()
JavaScript Number toPrecision()
The toPrecision() method is used to format a number to the specified length. If the length is more than the number then the decimal points and nulls are added to the number to format it to the precise length.
Syntax:-
Its syntax is:- number.toPrecision(x)
Return:-
Its return is:- number formatted to the specified precision.
Further Explanation:-
Parameter | Description |
x | Optional. The number of digits. |