Number.prototype.toPrecision()
Number.prototype.toPrecision() is a JavaScript method in the Number category. Returns a string with specified precision. The syntax is num.toPrecision(precision). A typical example: (1.234).toPrecision(2) // "1.2". A close sibling is Number.prototype.toFixed(), which formats a number using fixed-point notation. A close sibling is Number.prototype.toExponential(), which returns a string in exponential notation. A close sibling is Number.prototype.toString(), which returns a string in the specified radix (base). A close sibling is Number.isNaN(), which determines whether a value is NaN. More about this category: Number methods for numeric operations — toFixed, parseInt, isNaN, and more. Related Number methods: Number.prototype.toFixed(), Number.prototype.toExponential(), Number.prototype.toString(), Number.isNaN(), Number.isFinite(), Number.isInteger(), Number.isSafeInteger(), Number.parseFloat(). This page is part of the free JS Reference documentation covering 1027+ methods, each with syntax, parameters, return values, examples, and common pitfalls. You can try Number.prototype.toPrecision() immediately in the JavaScript playground, look up unfamiliar terms in the glossary, or return to the JS Reference homepage.