JavaScript - toPrecision() Number Object

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






The JavaScript toPrecision() method is responsible for returning a string representing the number object to the specified precision

Syntax

It will return a string representing a Number object in fixed-point or exponential notation rounded to precision significant digits.

The following example explains how to use method toLocaleString() i.e., num.toLocaleString(893.3424). Will convert number object into string.


Example

Try It Now



Other JavaScript Number Object Methods you might want to learn

toString()

valueOf()

toFixed()

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
toPrecision() Yes Yes Yes Yes Yes Yes Yes