Skip to content

JavaScript toPrecision() function | Number to a specified precision

  • by

JavaScript toPrecision() function is used to format a number to a specified length. This method returns a string representing the Number object to the specified precision.


Number object to specified precision with JavaScript toPrecision()

Simple example code format a number to a specified length.

<!DOCTYPE html>

    let num = 13.3714;
    let n = num.toPrecision(4);




JavaScript toPrecision() function

Do comment if you have any doubts or suggestions on this JS precision function.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *