JavaScript Number.toFixed() Method
JavaScript Number.toFixed() Method
The Number.toFixed()
method returns a string representing the given number using fixed-point notation.
Note: The number is rounded if necessary, and the fractional part is padded with zeros if necessary so that it has the specified length.
Note: If a number is greater or equal to 1e+21, this method simply calls Number.prototype.toString() and returns a string in exponential notation.
Example
Syntax
Parameter Values
Value | Type | Explanation |
---|---|---|
x | optional | The number of digits to appear after the decimal point. A range is between 0 and 20. If omitted, the default value is '0'. |
Return Value
Value | Explanation |
---|---|
string | Returns a string representing the given number using fixed-point notation. |
More Examples
Example
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.