Function padStart

  • Pads string on the left side if it's shorter than length. Padding characters are truncated if they exceed length.

    Parameters

    • string: string = ""

      The string to pad.

    • length: number = 0

      The padding length.

    • chars: string = " "

      The string used as padding.

    Returns string

    Returns the padded string.

    5.12.0

    padStart('abc', 6)
    // => ' abc'

    padStart('abc', 6, '_-')
    // => '_-_abc'

    padStart('abc', 2)
    // => 'abc'