AvailabilityJavaScript 1.5; JScript 5.5, ECMAScript v3 Synopsisnumber.toFixed(digits) Arguments
ReturnsA string representation of number that does not use exponential notation and has exactly digits digits after the decimal place. The number is rounded if necessary, and the fractional part is padded with zeros if necessary so that it has the specified length. If number is greater than 1e+21, this method simply calls Number.toString( ) and returns a string in exponential notation. Throws
Examplevar n = 12345.6789; n.toFixed( ); // Returns 12346: note rounding, no fractional part n.toFixed(1); // Returns 12345.7: note rounding n.toFixed(6); // Returns 12345.678900: note added zeros (1.23e+20).toFixed(2); // Returns 123000000000000000000.00 (1.23e-10).toFixed(2) // Returns 0.00 See AlsoNumber.toExponential( ), Number.toLocaleString( ), Number.toPrecision( ), Number.toString( ) |