Tweakr
    Preparing search index...

    Function padLeft

    • Pads a string on the left to reach the specified length.

      Parameters

      • str: string

        The string to pad.

      • length: number

        The desired total length of the string after padding.

      • char: string = " "

        The character to use for padding. Defaults to a space.

      Returns string

      The padded string.

      1.1.0

      padLeft("5", 3); // "  5"
      padLeft("42", 5, "0"); // "00042"