es-stl - v3.0.2
    Preparing search index...

    Function toFixed

    • Formats a value with fixed-point precision and removes insignificant trailing zeroes.

      Parameters

      • num: number

        Number to format.

      • OptionalfractionDigits: number

        Number of digits to keep after the decimal point.

      Returns string

      Fixed-point string normalized through Number().

      The value is first normalized with toSafeNumber. The formatted result is converted through Number(), so trailing zeroes generated by Number.prototype.toFixed() are removed.

      toFixed(0.101, 2);
      // => '0.1'
      toFixed(12, 2);
      // => '12'
      toFixed(Number.NaN, 2);
      // => '0'