toFixed

toFixed

> Functions

Returns a string containing the number x* written with exactly *digits digits after the decimal point: toFixed(1.0, 2) returns "1.00", where string gives "1.0".

The number is rounded to the nearest value, and a half rounds away from zero: toFixed(2.5, 0) returns "3" and toFixed(-2.5, 0) returns "-3". Rounding applies to the number as string writes it, so toFixed(1.005, 2) returns "1.01". The result always uses a dot, never scientific notation, and never "-0.00".

Parameters
Return
Note